OS Filesystem¶
Manage the filesystem provided by your OS.
In essence, an OSFS
is a thin layer over the io
and os
modules
of the Python standard library.
-
class
fs.osfs.
OSFS
(root_path, create=False, create_mode=511)[source]¶ Create an OSFS.
Parameters: - root_path (str or PathLike) – An OS path or path-like object to the location on your HD you wish to manage.
- create (bool) – Set to
True
to create the root directory if it does not already exist, otherwise the directory should exist prior to creating theOSFS
instance (defaults toFalse
). - create_mode (int) – The permissions that will be used to create
the directory if
create
isTrue
and the path doesn’t exist, defaults to0o777
.
Raises: fs.errors.CreateFailed
– Ifroot_path
does not exist, or could not be created.Examples
>>> current_directory_fs = OSFS('.') >>> home_fs = OSFS('~/') >>> windows_system32_fs = OSFS('c://system32')