eric7.SystemUtilities.FileSystemUtilities

Module implementing file system related utility functions.

Global Attributes

_DeviceFileMarker
_RemoteFileMarker

Classes

None

Functions

absolutePath Public method to convert a path relative to a start path to an absolute path.
absoluteUniversalPath Public method to convert a path relative to a start path with universal separators to an absolute path.
compactPath Function to return a compacted path fitting inside the given width.
deviceFileName Function to create a device (MicroPython) file name given a plain file name.
direntries Function returning a list of all files and directories.
findVolume Function to find the directory belonging to a given volume name.
fromNativeSeparators Function returning a path, that is using "/" separator characters.
getDirs Function returning a list of all directories below path.
getExecutablePath Function to build the full path of an executable file from the environment.
getExecutablePaths Function to build all full path of an executable file from the environment.
getUserMounts Function to determine all available user mounts.
getVolumeName Local function to determine the volume of a disk or device.
getWindowsExecutablePath Function to build the full path of an executable file from the environment on Windows platforms.
isDeviceFileName Function to check, if the given file name is a device file name.
isDrive Function to check, if a path is a Windows drive.
isExecutable Function to check, if a file is executable.
isPlainFileName Function to check, if the given file name is a plain (i.e.
isRemoteFileName Function to check, if the given file name is a remote file name.
isinpath Function to check for an executable file.
joinext Function to join a file extension to a path.
normabsjoinpath Function returning a normalized, absolute path of the joined parts passed into it.
normcaseabspath Function returning an absolute path, that is normalized with respect to its case and references.
normcasepath Function returning a path, that is normalized with respect to its case and references.
normjoinpath Function returning a normalized path of the joined parts passed into it.
plainFileName Function to create a plain file name given a device or remote file name.
relativeUniversalPath Function to convert a file path to a path relative to a start path with universal separators.
remoteFileName Function to create a remote file name given a plain file name.
samefilepath Function to compare two paths.
samepath Function to compare two paths.
splitPath Function to split a pathname into a directory part and a file part.
startfile Function to open the given file path with the system default application.
startsWithPath Function to check, if a path starts with a given start path.
toNativeSeparators Function returning a path, that is using native separator characters.


absolutePath

absolutePath(path, start)

Public method to convert a path relative to a start path to an absolute path.

path (str)
file or directory name to convert
start (str)
start path
Return:
absolute path
Return Type:
str
Up


absoluteUniversalPath

absoluteUniversalPath(path, start)

Public method to convert a path relative to a start path with universal separators to an absolute path.

path (str)
file or directory name to convert
start (str)
start path
Return:
absolute path with native separators
Return Type:
str
Up


compactPath

compactPath(path, width, measure=len)

Function to return a compacted path fitting inside the given width.

path (str)
path to be compacted
width (int)
width for the compacted path
measure (function(str))
reference to a function used to measure the length of the string
Return:
compacted path
Return Type:
str
Up


deviceFileName

deviceFileName(fileName)

Function to create a device (MicroPython) file name given a plain file name.

fileName (str)
plain file name
Return:
device file name
Return Type:
str
Up


direntries

direntries(path, filesonly=False, pattern=None, followsymlinks=True, checkStop=None, ignore=None, )

Function returning a list of all files and directories.

path (str)
root of the tree to check
filesonly (bool)
flag indicating that only files are wanted
pattern (str or list of str)
a filename pattern or list of filename patterns to check against
followsymlinks (bool)
flag indicating whether symbolic links should be followed
checkStop (function)
function to be called to check for a stop
ignore (list of str)
list of entries to be ignored
Return:
list of all files and directories in the tree rooted at path. The names are expanded to start with path.
Return Type:
list of str
Up


findVolume

findVolume(volumeName, findAll=False)

Function to find the directory belonging to a given volume name.

volumeName (str)
name of the volume to search for
findAll (bool (optional))
flag indicating to get the directories for all volumes starting with the given name (defaults to False)
Return:
directory path or list of directory paths for the given volume name
Return Type:
str or list of str
Up


fromNativeSeparators

fromNativeSeparators(path)

Function returning a path, that is using "/" separator characters.

path (str)
path to be converted
Return:
path with converted separator characters
Return Type:
str
Up


getDirs

getDirs(path, excludeDirs)

Function returning a list of all directories below path.

path (str)
root of the tree to check
excludeDirs (list of str)
base name of directories to ignore
Return:
list of all directories found
Return Type:
list of str
Up


getExecutablePath

getExecutablePath(file)

Function to build the full path of an executable file from the environment.

file (str)
filename of the executable to check
Return:
full executable name, if the executable file is accessible via the executable search path defined by the PATH environment variable, or an empty string otherwise.
Return Type:
str
Up


getExecutablePaths

getExecutablePaths(file)

Function to build all full path of an executable file from the environment.

file (str)
filename of the executable
Return:
list of full executable names, if the executable file is accessible via the executable search path defined by the PATH environment variable, or an empty list otherwise.
Return Type:
list of str
Up


getUserMounts

getUserMounts()

Function to determine all available user mounts.

Note: On Windows platforms all available drives are returned.

Return:
list of user mounts or drives
Return Type:
list of str
Up


getVolumeName

getVolumeName(diskName)

Local function to determine the volume of a disk or device.

Each disk or external device connected to windows has an attribute called "volume name". This function returns the volume name for the given disk/device.

Code from http://stackoverflow.com/a/12056414

Up


getWindowsExecutablePath

getWindowsExecutablePath(file)

Function to build the full path of an executable file from the environment on Windows platforms.

First an executable with the extension .exe is searched for, thereafter such with the extensions .cmd or .bat and finally the given file name as is. The first match is returned.

file (str)
filename of the executable to check
Return:
full executable name, if the executable file is accessible via the executable search path defined by the PATH environment variable, or an empty string otherwise.
Return Type:
str
Up


isDeviceFileName

isDeviceFileName(fileName)

Function to check, if the given file name is a device file name.

fileName (str)
file name to be checked
Return:
flag indicating a device file name
Return Type:
bool
Up


isDrive

isDrive(path)

Function to check, if a path is a Windows drive.

path (str)
path name to be checked
Return:
flag indicating a Windows drive
Return Type:
bool
Up


isExecutable

isExecutable(exe)

Function to check, if a file is executable.

exe (str)
filename of the executable to check
Return:
flag indicating executable status
Return Type:
bool
Up


isPlainFileName

isPlainFileName(fileName)

Function to check, if the given file name is a plain (i.e. local) file name.

fileName (str)
file name to be checked
Return:
flag indicating a local file name
Return Type:
bool
Up


isRemoteFileName

isRemoteFileName(fileName)

Function to check, if the given file name is a remote file name.

fileName (str)
file name to be checked
Return:
flag indicating a remote file name
Return Type:
bool
Up


isinpath

isinpath(file)

Function to check for an executable file.

file (str)
filename of the executable to check
Return:
flag indicating, if the executable file is accessible via the executable search path defined by the PATH environment variable.
Return Type:
bool
Up


joinext

joinext(prefix, ext)

Function to join a file extension to a path.

The leading "." of ext is replaced by a platform specific extension separator if necessary.

prefix (str)
the basepart of the filename
ext (str)
the extension part
Return:
the complete filename
Return Type:
str
Up


normabsjoinpath

normabsjoinpath(a, *p)

Function returning a normalized, absolute path of the joined parts passed into it.

a (str)
first path to be joined
p (str)
variable number of path parts to be joined
Return:
absolute, normalized path
Return Type:
str
Up


normcaseabspath

normcaseabspath(path)

Function returning an absolute path, that is normalized with respect to its case and references.

path (str)
file path
Return:
absolute, normalized path
Return Type:
str
Up


normcasepath

normcasepath(path)

Function returning a path, that is normalized with respect to its case and references.

path (str)
file path
Return:
case normalized path
Return Type:
str
Up


normjoinpath

normjoinpath(a, *p)

Function returning a normalized path of the joined parts passed into it.

a (str)
first path to be joined
p (str)
variable number of path parts to be joined
Return:
normalized path
Return Type:
str
Up


plainFileName

plainFileName(fileName)

Function to create a plain file name given a device or remote file name.

fileName (str)
device or remote file name
Return:
plain file name
Return Type:
str
Up


relativeUniversalPath

relativeUniversalPath(path, start)

Function to convert a file path to a path relative to a start path with universal separators.

path (str)
file or directory name to convert
start (str)
start path
Return:
relative path or unchanged path, if path does not start with the start path with universal separators
Return Type:
str
Up


remoteFileName

remoteFileName(fileName)

Function to create a remote file name given a plain file name.

fileName (str)
plain file name
Return:
remote file name
Return Type:
str
Up


samefilepath

samefilepath(f1, f2, followSymlinks=True)

Function to compare two paths. Strips the filename.

f1 (str)
first filepath for the compare
f2 (str)
second filepath for the compare
followSymlinks (bool (optional))
flag indicating to respect symbolic links for the comparison (i.e. compare the real paths) (defaults to True)
Return:
flag indicating whether the two paths represent the same path on disk
Return Type:
bool
Up


samepath

samepath(f1, f2, followSymlinks=True)

Function to compare two paths.

f1 (str)
first filepath for the compare
f2 (str)
second filepath for the compare
followSymlinks (bool (optional))
flag indicating to respect symbolic links for the comparison (i.e. compare the real paths) (defaults to True)
Return:
flag indicating whether the two paths represent the same path on disk
Return Type:
bool
Up


splitPath

splitPath(name)

Function to split a pathname into a directory part and a file part.

name (str)
path name
Return:
tuple containing directory name and file name
Return Type:
tuple of (str, str)
Up


startfile

startfile(filePath)

Function to open the given file path with the system default application.

filePath (str or Path)
file path to be opened
Return:
flag indicating a successful start of the associated application
Return Type:
bool
Up


startsWithPath

startsWithPath(path, start)

Function to check, if a path starts with a given start path.

path (str)
path to be checked
start (str)
start path
Return:
flag indicating that the path starts with the given start path
Return Type:
bool
Up


toNativeSeparators

toNativeSeparators(path)

Function returning a path, that is using native separator characters.

path (str)
path to be converted
Return:
path with converted separator characters
Return Type:
str
Up