scratch – Blame information for rev 115
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
115 | office | 1 | # TemporaryFilesystem |
2 | |||
3 | TemporaryFilesystem propose an API for temprary filesystem based on [Symfony |
||
4 | Filesystem Component](https://github.com/symfony/filesystem). |
||
5 | |||
6 | [![Build Status](https://travis-ci.org/romainneutron/Temporary-Filesystem.png?branch=master)](https://travis-ci.org/romainneutron/Temporary-Filesystem) |
||
7 | |||
8 | ## Usage |
||
9 | |||
10 | ```php |
||
11 | use Neutron\TemporaryFilesystem\TemporaryFilesystem; |
||
12 | |||
13 | $fs = TemporaryFilesystem::create(); |
||
14 | ``` |
||
15 | |||
16 | ## API Examples : |
||
17 | |||
18 | ### CreateTemporaryDirectory |
||
19 | |||
20 | CreateTemporaryDirectory creates a temporary directory with an optional mode : |
||
21 | |||
22 | ```php |
||
23 | $tempDir = $fs->createTemporaryDirectory($mode = 0755); |
||
24 | ``` |
||
25 | |||
26 | ### CreateTemporaryFile |
||
27 | |||
28 | CreateTemporaryFile creates an empty files in the temporary folder: |
||
29 | |||
30 | ```php |
||
31 | $fs->createTemporaryFile(); |
||
32 | |||
33 | // return an empty temporary files with a "thumb-" |
||
34 | // prefix, '.dcm' as suffix and 'jpg' as extension |
||
35 | $fs->createTemporaryFile('thumb-', '.dcm', 'jpg'); |
||
36 | ``` |
||
37 | |||
38 | ### CreateTemporaryFiles |
||
39 | |||
40 | CreateTemporaryFiles creates a set of empty files in the temporary folder: |
||
41 | |||
42 | ```php |
||
43 | // return an array of 5 path to temporary files |
||
44 | $fs->createTemporaryFiles(5); |
||
45 | |||
46 | // return an array of 5 path to empty temporary files with a "thumb-" |
||
47 | // prefix, '.dcm' as suffix and 'jpg' as extension |
||
48 | $fs->createTemporaryFiles(20, 'thumb-', '.dcm', 'jpg'); |
||
49 | ``` |
||
50 | |||
51 | This method is useful when dealing with libraries which encode images |
||
52 | depending on the filename extension. |
||
53 | |||
54 | ### CreateEmptyFile |
||
55 | |||
56 | CreateEmptyFile creates an empty file in the specified folder: |
||
57 | |||
58 | ```php |
||
59 | // return a path to an empty file inside the current working directory |
||
60 | $fs->createEmptyFile(getcwd()); |
||
61 | |||
62 | // return a path to an empty file in the "/home/romain" directory. The file |
||
63 | // has "original." as prefix, ".raw" as suffix and "CR2" as extension. |
||
64 | $fs->createEmptyFile("/home/romain", 'original.', '.raw', 'CR2'); |
||
65 | ``` |
||
66 | |||
67 | This method is particularly useful when dealing with concurrent process |
||
68 | writing in the same directory. |
||
69 | |||
70 | # License |
||
71 | |||
72 | Released under the MIT license |