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.

Members

Modifiers Member Description
+ const / Returns an instance of System.Directory that point to the sub-directory ident...
+ const absoluteFilePath Returns the path of the file identified by fileName under the directory as ...
+ const absolutePath Returns the directory path as an absolute path.
+ 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.
+ const filePath Returns the path of the file identified by fileName under the directory.
- @ g_lib Global library handle.
+ const getFile Returns the file identified by fileName under the directory as an instance ...
+ const getName Returns the name of the directory, excluding the path.
+ const getPath Returns the directory path.
+ @ const home Returns the user's home directory.
+ const isAbsolute Returns true if the directory's path is absolute; otherwise returns false.
+ 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 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...
- final path Internal directory path.
+ const relativeFilePath Returns the path of the file identified by fileName as a path relative to t...
+ 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...

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.absoluteFilePath

def (const self, fileName)

Returns the path of the file identified by fileName under the directory as an absolute path.

System.Directory.absolutePath

def (const self)

Returns the directory path as an absolute 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.

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.

System.Directory.filePath

def (const self, fileName)

Returns the path of the file identified by fileName under the directory.

System.Directory.g_lib

lib ('libmint-system')

Global library handle.

System.Directory.getFile

def (const self, fileName)

Returns the file identified by fileName under the directory as an instance of System.File.

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.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.

System.Directory.isReadable

def (const self)

Returns true if the directory is readable and we can open files by name; otherwise returns false.

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 "/").

System.Directory.isRoot

def (const self)

Returns true if the directory is the root directory; otherwise returns false.

System.Directory.isSubPath

def (const self, path)

Returns true if the path identified by path is a sub path of self; otherwise returns false.

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
    }
}

System.Directory.makeAbsolute

def (self)

Converts the directory path to an absolute path. If it is already absolute nothing happens.

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.relativeFilePath

def (const self, fileName)

Returns the path of the file identified by fileName as a path relative to the directory.

System.Directory.remove

def (self, fileName)

Removes the file or directory fileName. If fileName identify a directory, all its content is removbed recusively.

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.