You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/utils/fs.md
+81-30Lines changed: 81 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,10 +109,10 @@ if ($created) {
109
109
110
110
### Reading Files
111
111
112
-
Reading files means getting the content of a file. You can read files using the `readFile()` method. It takes in the file path and returns the file content.
112
+
Reading files means getting the content of a file. You can read files using the `read()` method. It takes in the file path and returns the file content.
@@ -254,24 +254,53 @@ You can check if a folder is empty using the `isEmpty()` method. It takes in the
254
254
$isEmpty = storage()->isEmpty('path/to/folder');
255
255
```
256
256
257
-
You can also get the contents of a folder using the `listDir()` method. It takes in the folder path and a key to sort the contents by. It returns an array of the folder contents.
257
+
You can also get the contents of a folder using the `list()` method. It takes in the folder path and a key to sort the contents by. It returns an array of the folder contents.
You can check if a file or folder exists using the `exists()` method. It takes in the file path and returns a boolean indicating whether the file exists.
292
+
293
+
```php
294
+
$exists = storage()->exists('path/to/file.txt');
295
+
```
296
+
297
+
This will return true if the path matches an existing folder or file, but if you want to get more specific, you can use the `isFile()` and `isFolder()` methods to check if a path is a file or folder.
There are instances where you might need to rename files or folders. Leaf provides a simple way to rename files and folders using the `rename()` method. It takes in 2 parameters:
@@ -361,6 +390,28 @@ if ($moved) {
361
390
}
362
391
```
363
392
393
+
## Symlinks/Shortcuts
394
+
395
+
Symlinks are shortcuts to files or folders. They allow you to access a file or folder from a different location. Leaf provides a simple way to create symlinks using the `symlink()` method. It takes in 2 parameters:
Streaming is a way to read and write data from a source or to a destination. Leaf provides a simple way to work with streams using the `stream()` function.
0 commit comments