User Tools

Site Tools


DzDir

DAZ Script directory access class.

More...

Inherits :

Enumerations

Static Methods

Constructors

DAZ Script
DzDir ( String path )

Methods

DAZ Script
StringabsFilePath ( String file )
StringabsoluteFilePath ( String fileName )
StringabsolutePath ()
StringabsPath ()
StringcanonicalPath ()
Booleancd ( String dirName )
BooleancdUp ()
Booleancopy ( String srcFile, String destFile )
Numbercount ()
StringdirName ()
ArrayentryList ( Array nameFilters, Filter filters=NoFilter, SortFlag sort=NoSort )
ArrayentryList ( Filter filters=NoFilter, SortFlag sort=NoSort )
ArrayentryList ( String nameFilter, Filter filters=NoFilter, SortFlag sort=NoSort )
Booleanexists ( String name )
Booleanexists ()
BooleanfileExists ( String fileName )
StringfilePath ( String fileName )
Filterfilter ()
ArraygetFilesFromDir ( Array extentions, Boolean recursive=true )
BooleanisAbsolute ()
BooleanisReadable ()
BooleanisRelative ()
BooleanisRoot ()
BooleanmakeAbsolute ()
Booleanmkdir ( String dirName=“” )
Booleanmkdirs ( String dirName=“” )
Booleanmkpath ( String dirpath=“” )
Booleanmove ( String srcFile, String destFile )
ArraynameFilters ()
Stringpath ()
voidrefresh ()
StringrelativeFilePath ( String fileName )
Booleanremove ( String fileName )
Booleanrename ( String oldName, String newName )
Booleanrmdir ( String dirName=“” )
Booleanrmdirs ( String dirName=“” )
Booleanrmpath ( String dirPath=“” )
BooleansetCurrent ()
voidsetFilter ( Filter filters )
voidsetNameFilters ( Array nameFilters )
voidsetPath ( String path )
voidsetSorting ( SortFlag sort )
SortFlagsorting ()

Detailed Description

Provides access to the file system directory structure. It provides functions for creating, removing, traversing, and searching directories.

Enumerations


: Filter

Filtering options used by entryList().

  • Dirs - List directories that match the filters.
  • Files - List files that match the filters.
  • Drives - List drives that match the filters.
  • NoSymLinks - Do not list symbolic links.
  • AllEntries - List directories, files, drives and symbolic links.
  • All - List directories, files, drives and symbolic links.
  • TypeMask - Type Mask
  • Readable - List entries for which the application has read access. Needs to be combined with Dirs or Files.
  • Writable - List entries for which the application has write access. Needs to be combined with Dirs or Files.
  • Executable - List entries for which the application has execute access. Needs to be combined with Dirs or Files.
  • PermissionMask - Include Readable, Writable, and Executable entries
  • RWEMask - Include Readable, Writable, and Executable entries
  • Modified - Only list entries that have been modified.
  • Hidden - List hidden entries.
  • System - List system entries.
  • AccessMask - Access mask
  • AllDirs - List all directories; don't apply filters to directory names.
  • CaseSensitive - The filter should be treated as case sensitive.
  • NoDotAndDotDot - Do not list the special entries '.' and '..'.
  • NoDot - Do not list the special entry '.'.
  • NoDotDot - Do not list the special entry '..'.
  • NoFilter - Do not filter.

—–

: SortFlag

Sorting options used by entryList().

  • Name - Sort by name.
  • Time - Sort by time (modification time).
  • Size - Sort by size.
  • Unsorted - Do not sort.
  • SortByMask - Mask for Sort by
  • DirsFirst - Put the directories first, then the files.
  • Reversed - Reverse the sort order.
  • IgnoreCase - Sort case-insensitively.
  • DirsLast - Put the files first, then the directories.
  • LocaleAware - Sort items appropriately using the current locale settings.
  • Type - Sort by file type (extension).
  • NoSort - Not sorted by default.

Static Methods


String : cleanPath( String path )

Return Value:

  • The simplest version of the input, but not the canonical path; removes multiple adjacent directory separators (e.g. “//”) and resolves any dot and/or dotdot (e.g. “.” or “..”) found in the path. Symbolic links are kept.

Since:

  • 4.9.3.35

DzDir : current()

Return Value:

  • The application's current directory. The directory is constructed using the absolute path of the current directory, ensuring that its path() will be the same as its absolutePath().

See Also:

Since:

  • 4.9.3.35

String : currentPath()

Return Value:

  • The absolute path of the application's current directory.

See Also:

Since:

  • 4.9.3.35

String : fromNativeSeparators( String pathName )

Return Value:

  • pathName using '/' as the path separator instead of the native path separator.

See Also:

Since:

  • 4.9.3.35

DzDir : home()

Return Value:

  • The user's home directory. The directory is constructed using the absolute path of the home directory, ensuring that its path() will be the same as its absolutePath().

See Also:

Since:

  • 4.9.3.35

String : homePath()

Return Value:

  • The absolute path of the user's home directory. Under Windows this function will return the directory of the current user's profile. Under non-Windows operating systems the HOME environment variable is used if it exists, otherwise the path returned by the rootPath().

Attention:

  • Under Windows, if the directory of the current user's profile does not exist or cannot be retrieved, the following alternatives will be checked (in the given order) until an existing and available path is found: * The path specified by the USERPROFILE environment variable.
  • The path formed by concatenating the HOMEDRIVE and HOMEPATH environment variables.
  • The path specified by the HOME environment variable.
  • The path returned by the rootPath() function (which uses the SystemDrive environment variable).
  • The C:/ directory.

Since:

  • 4.9.3.35

Boolean : isAbsolutePath( String path )

Return Value:

  • true if path is absolute, otherwise false.

Since:

  • 4.9.3.35

Boolean : isRelativePath( String path )

Return Value:

  • true if path is relative, otherwise false.

Since:

  • 4.9.3.35

Boolean : match( String filter, String fileName )

Return Value:

  • true if fileName matches the wildcard (glob) pattern filter, otherwise false. The filter may contain multiple patterns separated by spaces or semicolons. The matching is case insensitive.

Since:

  • 4.9.3.35

Boolean : match( Array filters, String fileName )

Return Value:

  • true if fileName matches any of the wildcard (glob) patterns in the list of filters, otherwise false. The matching is case insensitive.

Since:

  • 4.9.3.35

DzDir : root()

Return Value:

  • The root directory. The directory is constructed using the absolute path of the root directory, ensuring that its path() will be the same as its absolutePath().

See Also:

Since:

  • 4.9.3.35

String : rootPath()

Return Value:

  • The absolute path of the root directory. For Windows this normally returns “c:/”; i.e. the root of the system drive. For Mac OS X this returns “/”.

See Also:

Since:

  • 4.9.3.35

String : separator()

Return Value:

  • The native directory separator; “\” under Windows, “/” under Mac OS X.

Attention:

  • You do not need to use this function to build file paths. If you always use “/”, your paths will be translated to conform to the underlying operating system. If you want to display paths to the user using their operating system's separator use toNativeSeparators().

Since:

  • 4.9.3.35

Boolean : setCurrent( String path )

Sets the application's current working directory to path.

Return Value:

  • true if the directory was successfully changed, otherwise false.

See Also:

Since:

  • 4.9.3.35

DzDir : temp()

Return Value:

  • The system's temporary directory. The directory is constructed using the absolute path of the temp directory, ensuring that its path() will be the same as its absolutePath().

See Also:

Since:

  • 4.9.3.35

String : tempPath()

Return Value:

  • The absolute path of the system's temporary directory. On Windows this is usually the path in the TEMP or TMP environment variable. On Mac OS X this is the path in the TMPDIR environment variable or /tmp if TMPDIR is not defined. Whether a directory separator is added to the end or not, depends on the operating system.

See Also:

Since:

  • 4.9.3.35

String : toNativeSeparators( String pathName )

Return Value:

  • pathName with the '/' separators converted to separators that are appropriate for the underlying operating system. On Windows, '/' will be converted to '\'. On Mac OS X the returned string may be the same as pathName.

See Also:

Since:

  • 4.9.3.35

Constructors


DzDir( String path )

Creates a directory object with the given path.

Parameter(s):

  • path - The path of the directory.

Methods


String : absFilePath( String file )

Deprecated

Use absoluteFilePath() instead.


String : absoluteFilePath( String fileName )

Parameter(s):

  • fileName - The name of the file get the absolute path for.

Return Value:

  • The absolute path (a path that starts with “/” or with a drive specification) to file, which may contain symbolic links, but never contains redundant “.”, “..” or multiple separators. Does not check if the file actually exists in the directory.

Since:

  • 4.9.3.35

String : absolutePath()

Return Value:

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

Since:

  • 4.9.3.35

String : absPath()

Deprecated

Use absolutePath() instead.


String : canonicalPath()

Return Value:

  • The canonical path, i.e. a path without symbolic links or redundant “.” or “..” elements.

Boolean : cd( String dirName )

Changes the current directory to dirName.

Parameter(s):

  • dirName - The path to change to; can be relative or absolute.

Return Value:

  • true if dirName exists and is readable, otherwise false.

Boolean : cdUp()

Changes the directory by moving one directory up from the current directory.

Return Value:

  • true if the new directory exists and is readable, otherwise false.

Boolean : copy( String srcFile, String destFile )

Makes a copy of a file.

Parameter(s):

  • srcFile - The path of the source file to copy.
  • destFile - The path of the file that source will be copied to.

Return Value:

  • true if srcFile and destFile are the same or if the operation is successful, otherwise false.

Number : count()

Return Value:

  • The total number of directories and files in the directory.

Since:

  • 4.9.3.35

String : dirName()

Return Value:

  • The the name of the directory (not the whole path, just the folder name). If the directory has no name (e.g. it is the root directory) an empty string is returned.

Array : entryList( Array nameFilters, Filter filters=NoFilter, SortFlag sort=NoSort )

TODO: Add description.


Array : entryList( Filter filters=NoFilter, SortFlag sort=NoSort )

TODO: Add description.


Array : entryList( String nameFilter, Filter filters=NoFilter, SortFlag sort=NoSort )

TODO: Add description.


Boolean : exists( String name )

Parameter(s):

  • name - The name of the file to check for.

Return Value:

  • true if the file exists, otherwise false.

Attention:

  • Unless name contains an absolute file path, the file name is assumed to be relative to the directory itself, so this function is typically used to check for the presence of files within a directory.

Since:

  • 4.9.3.35

Boolean : exists()

Return Value:

  • true if the directory exists, otherwise false.

Attention:

  • If a file with the same name is found this function will return false.

Boolean : fileExists( String fileName )

Deprecated

Use exists( String ) instead.


String : filePath( String fileName )

Return Value:

  • The path of a file named file in the directory; does not check if the file actually exists.

Attention:

  • If the directory is relative the returned path name will also be relative. Redundant multiple separators or “.” and “..” directories in fileName are not removed.

Filter : filter()

Return Value:

  • The value set by setFilter().

Since:

  • 4.9.3.35

Array : getFilesFromDir( Array extentions, Boolean recursive=true )

Parameter(s):

  • extentions - Aa array containing extentions of files to find; format of strings should be “*.ext”.
  • recursive - If true, the retrieval of file paths should recurse sub-directories.

Return Value:

  • An array containing the absolute paths of files under the directory.

Boolean : isAbsolute()

Return Value:

  • true if the directory's path is absolute, otherwise false.

Boolean : isReadable()

Return Value:

  • true if the directory is readable and we can open files by name, otherwise false.

Boolean : isRelative()

Return Value:

  • true if the directory path is relative, otherwise false.

Boolean : isRoot()

Return Value:

  • true if the directory is the root directory, otherwise false.

Attention:

  • If the directory is a symbolic link to the root directory this function returns false. If you want to test for this use canonicalPath().

Boolean : makeAbsolute()

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

Return Value:

  • true if the conversion succeeded, otherwise false.

Since:

  • 4.9.3.35

Boolean : mkdir( String dirName=“” )

Creates a new directory.

Parameter(s):

  • dirName - The relative path of a sub-directory to create. If empty (default), this directory's absolute path will be used.

Return Value:

  • true if dirName does not already exist when this function is called and the sub-directory is successfully created, otherwise false.

Boolean : mkdirs( String dirName=“” )

Deprecated

Use mkpath() instead.


Boolean : mkpath( String dirpath=“” )

Creates all directories that do not already exist in dirpath.

Parameter(s):

  • dirpath - The path of the directories to create.

Return Value:

  • true if successful (the path already exists when this function is called), otherwise false.

Boolean : move( String srcFile, String destFile )

Moves a file to a new location.

Parameter(s):

  • srcFile - The path of the source file to move.
  • destFile - The path that the file will be moved to.

Return Value:

  • true if srcFile and destFile are the same or if the operation is successful, otherwise false.

Array : nameFilters()

Return Value:

Since:

  • 4.9.3.35

String : path()

Return Value:

  • The path of this directory. This may contain symbolic links, but never contains redundant “.”, “..” or multiple separators.

void : refresh()

Refreshes the directory information.


String : relativeFilePath( String fileName )

Return Value:

  • The path to file, relative to the current directory; does not check if the file actually exists.

Boolean : remove( String fileName )

Removes fileName from this directory.

Parameter(s):

  • fileName - The relative path of the file to remove.

Return Value:

  • true if the file is removed successfully, otherwise false.

Boolean : rename( String oldName, String newName )

Renames a file or directory from oldName to newName.

Parameter(s):

  • oldName - The relative path of the file/folder to rename.
  • newName - The relative path to rename the file/folder to.

Return Value:

  • true if successful, otherwise false.

Boolean : rmdir( String dirName=“” )

Removes a directory.

Parameter(s):

  • dirName - The relative path of a sub-directory to remove. If empty (default), this directory's absolute path will be used.

Return Value:

  • true if dirName exists when this function is called, the directory is empty and the sub-directory is successfully removed, otherwise false.

Boolean : rmdirs( String dirName=“” )

Deprecated

Use rmpath() instead.


Boolean : rmpath( String dirPath=“” )

Removes all directories that exist in dirpath, provided that they are empty. This is the opposite of mkpath().

Parameter(s):

  • dirpath - The path to remove.

Return Value:

  • true if successful, otherwise false.

Boolean : setCurrent()

Sets the current working directory of the application to be this directory.

Return Value:

  • true if the current working directory was changed, otherwise false.

void : setFilter( Filter filters )

TODO: Add description.


void : setNameFilters( Array nameFilters )

Sets the name filters used by entryList() to the list of filters specified by nameFilters. Each name filter is a wildcard (globbing) filter that understands * and ? wildcards.

Since:

  • 4.9.3.35

void : setPath( String path )

Sets the path of this directory to newPath.


void : setSorting( SortFlag sort )

Sets the sort order used by entryList(). The sort is specified by OR-ing values from the enum SortFlag.

Since:

  • 4.9.3.35

SortFlag : sorting()

Return Value:

Since:

  • 4.9.3.35