Filesystem InterfaceΒΆ
The following methods are available in all PyFilesystem implementation:
- close() Close the filesystem and free any resources
- copy() Copy a file to a new location
- copydir() Recursively copy a directory to a new location
- cachehint() Permit implementation to use aggressive caching for performance reasons
- createfile() Create a file with data
- desc() Return a short descriptive text regarding a path
- exists() Check whether a path exists as file or directory
- getcontents() Returns the contents of a file as a string
- getinfo() Return information about the path e.g. size, mtime
- getmeta() Get the value of a filesystem meta value, if it exists
- getmmap() Gets an mmap object for the given resource, if supported
- getpathurl() Get an external URL at which the given file can be accessed, if possible
- getsize() Returns the number of bytes used for a given file or directory
- getsyspath() Get a file’s name in the local filesystem, if possible
- hasmeta() Check if a filesystem meta value exists
- haspathurl() Check if a path maps to an external URL
- hassyspath() Check if a path maps to a system path (recognized by the OS)
- ilistdir() Generator version of the listdir() method
- ilistdirinfo() Generator version of the listdirinfo() method
- isdir() Check whether a path exists and is a directory
- isdirempty() Checks if a directory contains no files
- isfile() Check whether the path exists and is a file
- listdir() List the contents of a directory
- listdirinfo() Get a directory listing along with the info dict for each entry
- makedir() Create a new directory
- makeopendir() Make a directory and returns the FS object that represents it
- move() Move a file to a new location
- movedir() Recursively move a directory to a new location
- open() Opens a file for read/writing
- opendir() Opens a directory and returns a FS object that represents it
- remove() Remove an existing file
- removedir() Remove an existing directory
- rename() Atomically rename a file or directory
- safeopen() Like open() but returns a NullFile if the file could not be opened
- setcontents() Sets the contents of a file as a string or file-like object
- setcontents_async() Sets the contents of a file asynchronously
- settimes() Sets the accessed and modified times of a path
- tree() Display an ascii rendering of the directory structure
- walk() Like listdir() but descends in to sub-directories
- walkdirs() Returns an iterable of paths to sub-directories
- walkfiles() Returns an iterable of file paths in a directory, and its sub-directories
See fs.base.FS for the method signature and full details.
If you intend to implement an FS object, see A Guide For Filesystem Implementers.