system.directory - Palamecia/mint GitHub Wiki
Module
load system.directory
This module provides the System.Directory class which allow interactions with the filesystem for one specific directory or for navigation over the filesystem.
Packages
Classes
System.Directory
This class is used to manipulate path names, access information regarding paths and files, and manipulate the underling file system.
The "/" character is used as a universal directory separator in the same way that "/" is used as a path separator in URLs. If you always use "/" as a directory separator, this class will translate your paths to conform to the underling operating system.
Public members
Modifiers | Member | Description |
---|---|---|
const |
/ | Returns an instance of System.Directory that point to the sub-directory ident... |
const |
cd | Changes directory to dir_name . An instance of Exception.SystemError is rais... |
const |
cdUp | Changes directory by moving one directory up from the current directory. An i... |
const |
contains | Returns true if the file or directory called fileName exists; otherwise r... |
@ const |
current | Returns the application's current directory. |
const |
exists | Returns true if the directory exists; otherwise returns false . An instanc... |
const |
getAbsoluteFilePath | Returns the path of the file identified by fileName under the directory as ... |
const |
getAbsolutePath | Returns the directory path as an absolute path. An instance of Exception.Syst... |
const |
getCanonicalFilePath | Returns the path of the file identified by fileName under the directory as ... |
const |
getCanonicalPath | Returns the directory path as a canonical path. An instance of Exception.Syst... |
const |
getFile | Returns the file identified by fileName under the directory as an instance ... |
const |
getFilePath | Returns the path of the file identified by fileName under the directory. |
const |
getName | Returns the name of the directory, excluding the path. |
const |
getPath | Returns the directory path. |
const |
getRelativeFilePath | Returns the path of the file identified by fileName as a path relative to t... |
@ const |
home | Returns the user's home directory. |
const |
isAbsolute | Returns true if the directory's path is absolute; otherwise returns false ... |
const |
isCanonical | Returns true if the directory's path is canonical; otherwise returns fals ... |
const |
isReadable | Returns true if the directory is readable and we can open files by name; ot... |
const |
isRelative | Returns true if the directory path is relative; otherwise returns false . ... |
const |
isRoot | Returns true if the directory is the root directory; otherwise returns fa ... |
const |
isSubPath | Returns true if the path identified by path is a sub path of self ; othe... |
const |
list | Returns an iterator on each file and directory name contained in this directo... |
const |
makeAbsolute | Converts the directory path to an absolute path. If it is already absolute no... |
const |
makeCanonical | Converts the directory path to a canonical path. If it is already canonical n... |
const |
mkdir | Creates a sub-directory called path with default permissions. An instance o... |
const |
mkpath | Creates the directory path path under this directory. The function will cre... |
const |
new | Creates a new instance pointing to the directory specified by the given pat ... |
const |
remove | Removes the file or directory fileName . If fileName identify a directory,... |
const |
rename | Renames a file or directory from oldFileName to newFileName . An instance ... |
const |
rmdir | Removes the directory specified by path . The directory must be empty to suc... |
const |
rmpath | Removes the directory path path . The function will remove all parent direct... |
@ const |
root | Returns the root directory. |
@ const |
setCurrent | Sets the application's current working directory to path . An instance of Ex... |
Private members
Modifiers | Member | Description |
---|---|---|
@ |
g_lib | Global library handle. |
final |
path | Internal directory path. |
Constants
Descriptions
System.Dir
System.Directory
Shortcut alias for System.Directory.
System.Directory./
def (self, path)
Returns an instance of System.Directory that point to the
sub-directory identified by path
.
System.Directory.cd
def (self, dir_name)
Changes directory to dir_name
.
An instance of Exception.SystemError is raised on error.
System.Directory.cdUp
def (self)
Changes directory by moving one directory up from the current directory.
An instance of Exception.SystemError is raised on error.
System.Directory.contains
def (const self, fileName)
Returns true
if the file or directory called fileName
exists;
otherwise returns false
.
An instance of Exception.SystemError is raised on error.
System.Directory.current
def ()
Returns the application's current directory.
System.Directory.exists
def (const self)
Returns true
if the directory exists; otherwise returns false
.
An instance of Exception.SystemError is raised on error.
System.Directory.g_lib
lib ('libmint-system')
Global library handle.
System.Directory.getAbsoluteFilePath
def (const self, fileName)
Returns the path of the file identified by fileName
under the
directory as an absolute path.
An instance of Exception.SystemError is raised on error.
System.Directory.getAbsolutePath
def (const self)
Returns the directory path as an absolute path.
An instance of Exception.SystemError is raised on error.
System.Directory.getCanonicalFilePath
def (const self, fileName)
Returns the path of the file identified by fileName
under the
directory as a canonical path.
An instance of Exception.SystemError is raised on error.
System.Directory.getCanonicalPath
def (const self)
Returns the directory path as a canonical path.
An instance of Exception.SystemError is raised on error.
System.Directory.getFile
def (const self, fileName)
Returns the file identified by fileName
under the directory as an
instance of System.File.
System.Directory.getFilePath
def (const self, fileName)
Returns the path of the file identified by fileName
under the
directory.
System.Directory.getName
def (const self)
Returns the name of the directory, excluding the path.
System.Directory.getPath
def (const self)
Returns the directory path.
System.Directory.getRelativeFilePath
def (const self, fileName)
Returns the path of the file identified by fileName
as a path
relative to the directory.
An instance of Exception.SystemError is raised on error.
System.Directory.home
def ()
Returns the user's home directory.
System.Directory.isAbsolute
def (const self)
Returns true
if the directory's path is absolute; otherwise returns
false
.
An instance of Exception.SystemError is raised on error.
System.Directory.isCanonical
def (const self)
Returns true
if the directory's path is canonical; otherwise returns
false
.
An instance of Exception.SystemError is raised on error.
System.Directory.isReadable
def (const self)
Returns true
if the directory is readable and we can open files by
name; otherwise returns false
.
An instance of Exception.SystemError is raised on error.
System.Directory.isRelative
def (const self)
Returns true
if the directory path is relative; otherwise returns
false
. (Under Unix a path is relative if it does not start with a
"/").
An instance of Exception.SystemError is raised on error.
System.Directory.isRoot
def (const self)
Returns true
if the directory is the root directory; otherwise returns
false
.
An instance of Exception.SystemError is raised on error.
System.Directory.isSubPath
def (const self, path)
Returns true
if the path identified by path
is a sub path of self
;
otherwise returns false
.
An instance of Exception.SystemError is raised on error.
System.Directory.list
def (const self, filter = none)
Returns an iterator on each file and directory name contained in this
directory. If filter
is given and is a valid regex, the returned
iterator is pre-filtered to provide only name that match the pattern.
The results of this method can be used with the System.Directory.getFile method to get extra informations.
Example:
dir = System.Directory(path)
for entry in dir.list() {
file = dir.getFile(entry)
if file.isDirectory() {
// handle directories
} else {
// handle files
}
}
An instance of Exception.SystemError is raised on error.
System.Directory.makeAbsolute
def (self)
Converts the directory path to an absolute path. If it is already absolute nothing happens.
An instance of Exception.SystemError is raised on error.
System.Directory.makeCanonical
def (self)
Converts the directory path to a canonical path. If it is already canonical nothing happens.
An instance of Exception.SystemError is raised on error.
System.Directory.mkdir
def (self, path)
Creates a sub-directory called path
with default permissions.
An instance of Exception.SystemError is raised on error.
System.Directory.mkpath
def (self, path)
Creates the directory path path
under this directory. The function
will create all parent directories necessary to create the directory.
An instance of Exception.SystemError is raised on error.
System.Directory.new
def (self, path = '.')
Creates a new instance pointing to the directory specified by the
given path
.
If path
is already an instance of System.Directory, this instance
is returned.
If path
provides a toDirectory
method, this method is used to
create the returned value; otherwise the variable is used as a string
to get the target directory path.
System.Directory.path
''
Internal directory path.
System.Directory.remove
def (self, fileName)
Removes the file or directory fileName
. If fileName
identify
a directory, all its content is removed recursively.
An instance of Exception.SystemError is raised on error.
System.Directory.rename
def (self, oldFileName, newFileName)
Renames a file or directory from oldFileName
to newFileName
.
An instance of Exception.SystemError is raised on error.
System.Directory.rmdir
def (self, path)
Removes the directory specified by path
. The directory must be empty
to succeed.
An instance of Exception.SystemError is raised on error.
System.Directory.rmpath
def (self, path)
Removes the directory path path
. The function will remove all parent
directories in path
, provided that they are empty. This is the opposite
of System.Directory.mkpath.
An instance of Exception.SystemError is raised on error.
System.Directory.root
def ()
Returns the root directory.
System.Directory.setCurrent
def (path)
Sets the application's current working directory to path
.
An instance of Exception.SystemError is raised on error.