The find command will ignore hidden files (those starting with a '.') and directories. If you need to scan hidden files then pass 'hidden: true'. If you need to return directories as well as files then use the 'types' argument.
var progress =Progress((file)=>print(file));
find('*.jpg', root: '\'
, progress: progress);
If you are process a large amount of results you may want to process them as you go rather than waiting for the full result list to be available.
By passing a 'Progress' into 'find' your progress will be called each time a matching file is found allowing to display the progressive results to the user.
Returns the list of files and directories in the current working directory. Use the 'find' function to get a list of any other directory.
List<String> entities = fileList;
The copy function copies a single file to a to a directory or a new file.
The above copyTree only copies files from '/tmp' that have an '.dart' extension.
The move function copies a single file to a directory or a file. If the 'to' argument is a file then the file is renamed.
The move function tries to use the native OS 'rename' function however if the destination is on a different device the rename will fail. In this case the move function performs a copy then delete.
The moveTree function allows you to move an entire tree or selected files from the tree to another location.
The moveTree function takes an optional 'filter' argument which allows you to selectively move files. Only those files that match the filter are moved.
var include =extension(entity)=='dart';
Like the move function the moveTree attempts an OS level rename but if that fails it resorts to performing a copy followed by a delete.
The delete function deletes a file.
If you pass the 'ask' argument to the delete function then the user will be prompted to confirm the delete action.
The deleteDir function deletes a directory.
If the directory isn't empty then a DeleteDirException will be thrown.
You can delete an entire directory tree using the recursive option:
The createDir function creates a directory. If the directory already exists then a CreateDirException will be thrown.
If the parent path doesn't exists then a CreateDirException will be thrown, to avoid this pass the recursive argument
The touch function updates the last modified date/time stamp of the passed file. If the 'create' argument is passed and the file doesn't exists then the file will be created. If the file doesn't exists and 'create: true' isn't passed then a 'TouchException' will be thrown.
touch('fred.txt, create: true');
The 'exists' function checks if a file, directory or symlink exists.
Test if a file or directory is writable.
Test if a file or directory is readable.
Test if a file or directory is executable.
Test if the given path is a file.
Test if the given path is a symbolic link.
Test if the given path is a directory.
Sets the last modified date/time stamp on give path.. This is similar to touch exception that you can choose the date/time.
Returns a DateTime reflecting the last modified date/time stamp of the given path.
DateTime modified =lastModifed('/fred.txt');
Calculates the sha256 hash of a file's content generating essentially a unique signature or checksum for the file.
This is likely to be an expensive operation if the file is large. You can use this method to check if a file has changes since the last time you took the file's hash.