|
1 | | -# Namespace: Trihydera\File |
| 1 | +# File |
2 | 2 |
|
3 | | -## Class: FileInfo |
4 | | - |
5 | | -Retrieves information about files in a directory, including file details like size, hash, and modification time. |
6 | | - |
7 | | -### Constructor |
8 | | - |
9 | | -#### `__construct($dir)` |
10 | | - |
11 | | -- **Description:** FileInfo constructor. |
12 | | -- **Parameters:** |
13 | | - - `$dir` (string): The directory path to retrieve file information from. |
14 | | - |
15 | | -### Methods |
16 | | - |
17 | | -#### `getInfo()` |
18 | | - |
19 | | -- **Description:** Get information about files in the directory. |
20 | | -- **Returns:** An array containing details of files in the directory. |
21 | | - |
22 | | -#### `listFilesRecursively($dir, &$details)` |
23 | | - |
24 | | -- **Description:** Recursively list files in a directory and gather details. |
25 | | -- **Parameters:** |
26 | | - - `$dir` (string): The directory path to list files from. |
27 | | - - `$details` (array): Reference to an array to store file details. |
28 | | - |
29 | | -#### `formatSize($bytes)` |
30 | | - |
31 | | -- **Description:** Format file size in human-readable format. |
32 | | -- **Parameters:** |
33 | | - - `$bytes` (int): The size of the file in bytes. |
34 | | -- **Returns:** The formatted file size with appropriate units. |
35 | | - |
36 | | ---- |
37 | | - |
38 | | -## Class: FileTypes |
39 | | - |
40 | | -Defines different file types along with their categories and purposes. |
41 | | - |
42 | | -### Properties |
43 | | - |
44 | | -#### `$types` |
45 | | - |
46 | | -- **Description:** Array containing file types with their categories and purposes. |
47 | | -- **Type:** array |
48 | | -- **Values:** |
49 | | - - `exe`: Windows - Executable file |
50 | | - - `msi`: Windows - Windows Installer Package |
51 | | - - `jpg`: Image - JPEG Image |
52 | | - - `png`: Image - PNG Image |
53 | | - - `txt`: Text - Plain Text File |
54 | | - - `pdf`: Document - PDF Document |
55 | | - - `doc`: Document - Microsoft Word Document |
56 | | - - `xlsx`: Document - Microsoft Excel Spreadsheet |
57 | | - - `zip`: Archive - Compressed Archive |
58 | | - - `mp3`: Audio - MP3 Audio File |
59 | | - |
60 | | ---- |
61 | | - |
62 | | -## Class: JsonFile |
63 | | - |
64 | | -Handles reading and writing JSON data to files. |
65 | | - |
66 | | -### Methods |
67 | | - |
68 | | -#### `read($file)` |
69 | | - |
70 | | -- **Description:** Read JSON data from a file. |
71 | | -- **Parameters:** |
72 | | - - `$file` (string): The path to the JSON file. |
73 | | -- **Returns:** The decoded JSON data. |
74 | | -- **Throws:** `\Exception` If the file path is invalid. |
75 | | - |
76 | | -#### `write($file, $data)` |
77 | | - |
78 | | -- **Description:** Write JSON data to a file. |
79 | | -- **Parameters:** |
80 | | - - `$file` (string): The path to the JSON file. |
81 | | - - `$data` (array): The data to be encoded as JSON and written to the file. |
82 | | -- **Throws:** `\Exception` If the file path is invalid. |
| 3 | +File tools for getting file info and working with json files |
0 commit comments