@@ -55,8 +55,8 @@ const nonExistentFile = new File('path/to/nonExistent/file.txt', Buffer.from('Fi
5555// Now existentFile and nonExistentFile instances are created, but not loaded/created
5656
5757// using load here because the file already exists, if using create, would generate an exception
58- // property withContent if true, will save the file content in the instance, Be careful with big files
5958existentFile .loadSync ({ withContent: true })
59+ // property withContent if true, will save the file content in the instance, Be careful with big files
6060nonExistentFile .createSync ().loadSync ({ withContent: true })
6161
6262// now the files will have this properties
@@ -75,8 +75,16 @@ console.log(existentFile.getContentSync()) // Some Buffer instance
7575// you can use toJSON method to get the instance informations in JSON
7676console .log (existentFile .toJSON ()) // { ...infos }
7777
78+ // you can make a copy from existentFile using copy
79+ console .log (existentFile .copySync (' path/to/copy.txt' ))
80+
81+ // you can move existentFile to other path using move
82+ console .log (existentFile .moveSync (' path/to/move.txt' ))
83+
7884// File uses readable streams in async methods to not block the event loop when handling huge files content
7985await existentFile .load ()
86+ await existentFile .copy ()
87+ await existentFile .move ()
8088await existentFile .remove ()
8189await existentFile .create ()
8290await existentFile .getContent ()
@@ -99,11 +107,10 @@ const nonExistentFolder = new Folder('path/to/nonExistent/folder')
99107// Now existentFolder and nonExistentFolder instances are created, but not loaded/created
100108
101109// using load here because the file already exists, if using create, would generate an exception
110+ existentFolder .loadSync ({ withSub: true , withFileContent: false })
102111
103112// property withSub if true, will load files and subFolders from the folder
104113// property withFileContent if true, will get the content of all files in the folder, Be careful with big files
105-
106- existentFolder .loadSync ({ withSub: true , withFileContent: false })
107114nonExistentFolder .createSync ().loadSync ({ withSub: true , withFileContent: true })
108115
109116// now the folders will have this properties
@@ -118,6 +125,12 @@ existentFolder.removeSync() // void
118125// you can use toJSON method to get the instance informations in JSON
119126console .log (existentFolder .toJSON ()) // { ...infos }
120127
128+ // you can make a copy from existentFolder using copy
129+ console .log (existentFolder .copySync (' path/to/copy' ))
130+
131+ // you can move existentFolder to other path using move
132+ console .log (existentFolder .moveSync (' path/to/move' ))
133+
121134// you can use getFilesByPattern method to get all files in the folder that match some pattern
122135// if recursive is true, will go inside subFolders too
123136const recursive = true
@@ -128,6 +141,8 @@ console.log(existentFolder.getFoldersByPattern('path/to/**/folder', recursive))
128141
129142// Folder uses readable streams in async methods to not block the event loop when handling huge files content
130143await existentFolder .load ()
144+ await existentFolder .copy ()
145+ await existentFolder .move ()
131146await existentFolder .remove ()
132147await existentFolder .create ()
133148```
0 commit comments