Dir
class provides access to directory structures and their
contents in a platform-independent way. It provides a means of listing
directory content, creating filenames with proper path separators,
etc.
An example use of the Dir class is:
var dir = new Dir; var codeFiles = dir.entryList('*.cpp'); for (var i = 0; i < codeFiles.length; ++i) print(codeFiles[i]);
Dirs; List directories only.
Files; List files only.
Drives; List disk drives only.
NoSymLinks; Do not list symbolic links (ignored by operating systems that don't support symbolic links).
All; List directories, files, drives and symlinks (this does not list broken symlinks unless you specify System).
TypeMask; A mask for the the Dirs, Files, Drives and NoSymLinks flags.
Readable; List files for which the application has read access.
Writable; List files for which the application has write access.
Executable; List files for which the application has execute access. Executables must be combined with Dirs or Files.
RWEMask; A mask for the Readable, Writable and Executable flags.
Modified; Only list files that have been modified (ignored under Unix).
Hidden; List hidden files (on Unix, files starting with a .).
System; List system files (on Unix, FIFOs, sockets, and device files)
AccessMask; A mask for the Readable, Writable, Executable Modified, Hidden and System flags
Name; Sort by name.
Time; Sort by time (modification time).
Size; Sort by file size.
Unsorted; Do not sort.
SortByMask; A Mask for Name, Time and Size.
DirsFirst; Put the directories first, then the files.
Reversed; Reverse the sort order.
IgnoreCase; Sort case-insensitively.
current : String; The current directory.
home : String; The home directory.
root : String; The root directory.
drives : String[]; An array of strings containing the drive names (c:, d:, etc); empty on Unix.
cleanDirPath( filePath : String ) : String; Removes all multiple
directory separators "/" and resolves any "."s or ".."s found in the
path, filePath.
convertSeparators( pathName : String ) : String; Returns pathName with the "/" separators converted to separators that are appropriate for the underlying operating system.
Dir( path : String ); Creates a directory object for path
path. If path
is empty, the current directory is used.
name : String; Contains the name of the directory; this is not the same as the path, e.g. a directory with the name "mail", might have the path "/var/spool/mail"
path : String; Contains the path, this may contain symbolic links, but never contains redundant ".", "..", or multiple separators.
absPath : String; Contains the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", "..", or multiple separators.
canonicalPath : String; Contains the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements.
readable : Boolean; True if the directory is readable; otherwise false.
exists : Boolean; True if the directory exists; otherwise false.
filePath( fileName : String ) : String; Returns the path name of
the file fileName
in the directory.
absFilePath( fileName : String ) : String; Returns the absolute
path name of the file fileName
in the directory.
cd( dirName : String ); Changes the Dir's directory to dirName
if possible; otherwise throws an exception.
cdUp(); Changes directory by moving one directory up from the Dir's current directory if possible; otherwise throws an exception.
entryList( filter : String, filterSpec : Number, sortSpec : Number
) : String[]; Returns a list of the names of all the files and
directories in the directory, ordered in accordance with sortSpec
and filtered in accordance with filterSpec.
mkdir( dirName : String ); Creates the directory dirName
if
possible; otherwise throws an exception.
mkdir(); Creates this directory if possible possible; otherwise throws an exception.
mkdirs( dirName : String ); Creates the directory tree dirName
if possible; otherwise throws an exception.
mkdirs(); Creates this directory tree if possible; otherwise throws an exception.
rmdir( dirName : String ); Deletes the directory dirName
if
possible; otherwise throws an exception.
rmdir(); Deletes this directory if possible; otherwise throws an exception.
rmdirs( dirName : String ); Deletes the directory structure dirName if possible; otherwise throws an exception.
rmdirs(); Deletes this directory structure if possible; otherwise throws an exception.
fileExists( fileName : String ) : Boolean; Returns true if the file
fileName
exists; otherwise returns false.
setCurrent(); Sets the application's current working directory to this directory if possible; otherwise throws an exception.