Dir Class Reference

The 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]);
  • 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.

Qt uses "/" as a directory separator throughout (although it understands the conventions of the platform it is used on). If you are working with paths, use "/" within your code, and use convertSeparators() when you want to display a path to the user.
  • 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.