@@ -21,6 +21,14 @@ interface VmSafe {
2121 string url;
2222 }
2323
24+ struct DirEntry {
25+ string errorMessage;
26+ string path;
27+ uint64 depth;
28+ bool isDir;
29+ bool isSymlink;
30+ }
31+
2432 struct FsMetadata {
2533 bool isDir;
2634 bool isSymlink;
@@ -113,30 +121,66 @@ interface VmSafe {
113121 function startBroadcast (uint256 privateKey ) external ;
114122 // Stops collecting onchain transactions
115123 function stopBroadcast () external ;
116- // Reads the entire content of file to string
124+
125+ // Get the path of the current project root.
126+ function projectRoot () external view returns (string memory path );
127+ // Reads the entire content of file to string. `path` is relative to the project root.
117128 function readFile (string calldata path ) external view returns (string memory data );
118- // Reads the entire content of file as binary. Path is relative to the project root.
129+ // Reads the entire content of file as binary. `path` is relative to the project root.
119130 function readFileBinary (string calldata path ) external view returns (bytes memory data );
120- // Get the path of the current project root
121- function projectRoot () external view returns (string memory path );
122- // Get the metadata for a file/directory
123- function fsMetadata (string calldata fileOrDir ) external returns (FsMetadata memory metadata );
124- // Reads next line of file to string
131+ // Reads next line of file to string.
125132 function readLine (string calldata path ) external view returns (string memory line );
126133 // Writes data to file, creating a file if it does not exist, and entirely replacing its contents if it does.
134+ // `path` is relative to the project root.
127135 function writeFile (string calldata path , string calldata data ) external ;
128136 // Writes binary data to a file, creating a file if it does not exist, and entirely replacing its contents if it does.
129- // Path is relative to the project root.
137+ // `path` is relative to the project root.
130138 function writeFileBinary (string calldata path , bytes calldata data ) external ;
131139 // Writes line to file, creating a file if it does not exist.
140+ // `path` is relative to the project root.
132141 function writeLine (string calldata path , string calldata data ) external ;
133142 // Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.
143+ // `path` is relative to the project root.
134144 function closeFile (string calldata path ) external ;
135- // Removes file. This cheatcode will revert in the following situations, but is not limited to just these cases:
136- // - Path points to a directory.
145+ // Removes a file from the filesystem.
146+ // This cheatcode will revert in the following situations, but is not limited to just these cases:
147+ // - `path` points to a directory.
137148 // - The file doesn't exist.
138149 // - The user lacks permissions to remove the file.
150+ // `path` is relative to the project root.
139151 function removeFile (string calldata path ) external ;
152+ // Creates a new, empty directory at the provided path.
153+ // This cheatcode will revert in the following situations, but is not limited to just these cases:
154+ // - User lacks permissions to modify `path`.
155+ // - A parent of the given path doesn't exist and `recursive` is false.
156+ // - `path` already exists and `recursive` is false.
157+ // `path` is relative to the project root.
158+ function createDir (string calldata path , bool recursive ) external ;
159+ // Removes a directory at the provided path.
160+ // This cheatcode will revert in the following situations, but is not limited to just these cases:
161+ // - `path` doesn't exist.
162+ // - `path` isn't a directory.
163+ // - User lacks permissions to modify `path`.
164+ // - The directory is not empty and `recursive` is false.
165+ // `path` is relative to the project root.
166+ function removeDir (string calldata path , bool recursive ) external ;
167+ // Reads the directory at the given path recursively, up to `max_depth`.
168+ // `max_depth` defaults to 1, meaning only the direct children of the given directory will be returned.
169+ // Follows symbolic links if `follow_links` is true.
170+ function readDir (string calldata path ) external view returns (DirEntry[] memory entries );
171+ function readDir (string calldata path , uint64 maxDepth ) external view returns (DirEntry[] memory entries );
172+ function readDir (string calldata path , uint64 maxDepth , bool followLinks )
173+ external
174+ view
175+ returns (DirEntry[] memory entries );
176+ // Reads a symbolic link, returning the path that the link points to.
177+ // This cheatcode will revert in the following situations, but is not limited to just these cases:
178+ // - `path` is not a symbolic link.
179+ // - `path` does not exist.
180+ function readLink (string calldata linkPath ) external view returns (string memory targetPath );
181+ // Given a path, query the file system to get information about a file, directory, etc.
182+ function fsMetadata (string calldata path ) external view returns (FsMetadata memory metadata );
183+
140184 // Convert values to a string
141185 function toString (address value ) external pure returns (string memory stringifiedValue );
142186 function toString (bytes calldata value ) external pure returns (string memory stringifiedValue );
0 commit comments