1 | <?php |
||
4 | class FileDescriptor { |
||
5 | |||
6 | use FileOperationTrait; |
||
7 | |||
8 | /** |
||
9 | * Creates a new FileDescriptor from SplFileInfo |
||
10 | * |
||
11 | * @param \SplFileInfo $fileInfo |
||
12 | * @return FileDescriptor |
||
13 | */ |
||
14 | public static function fromFileInfo(\SplFileInfo $fileInfo) { |
||
17 | |||
18 | public function __construct($filename) { |
||
21 | |||
22 | /** |
||
23 | * Tells whether this is a regular file |
||
24 | * |
||
25 | * @return boolean Returns TRUE if the filename exists and is a regular file, FALSE otherwise. |
||
26 | */ |
||
27 | public function isFile() { |
||
30 | |||
31 | /** |
||
32 | * Tells whether the filename is a '.' or '..' |
||
33 | * |
||
34 | * @return boolean |
||
35 | */ |
||
36 | public function isDot() { |
||
39 | |||
40 | /** |
||
41 | * Tells whether this is a directory |
||
42 | * |
||
43 | * @return boolean Returns TRUE if the filename exists and is a directory, FALSE otherwise. |
||
44 | */ |
||
45 | public function isDir() { |
||
48 | |||
49 | /** |
||
50 | * Converts this file descriptor into a file object |
||
51 | * |
||
52 | * @return File |
||
53 | */ |
||
54 | public function toFile() { |
||
57 | |||
58 | /** |
||
59 | * Converts this file descriptor into a directory object |
||
60 | * |
||
61 | * @return Directory |
||
62 | */ |
||
63 | public function toDirectory() { |
||
66 | |||
67 | /** |
||
68 | * Deletes the file |
||
69 | */ |
||
70 | public function delete() { |
||
77 | |||
78 | /** |
||
79 | * String representation of this file as pathname |
||
80 | */ |
||
81 | public function __toString() { |
||
84 | } |
||
85 |