Class File System
Divider

The File System class represents a file system.  There is one object of this class in the standard library called File.  Many of the functions in this class (especially functions that modify the status of a file) do not work on files that are open in any process.

The FileName input parameter taken by many of these functions should include the drive, path and filename of a file. If the drive is omitted on DOS/Windows systems, the current drive is assumed. If no path is provided, or if a relative path is given, the current directory for the thread is used as a base. Slashes and backslashes (/, \) are recognized as path separators on all implementations.

Function CreateStream() Returns @ File Stream;

Creates (with New) and returns a File Stream object designed to access a file in the file system.  The caller is responsible for freeing the stream with Delete.

Current Directory Management

Function GetCurDir() Returns String;
Function SetCurDir (NewDir: String @) Returns Boolean;

GetCurDir retrieves the path of the current drive and directory; SetCurDir sets the current directory (and drive, if provided.) If a relative path is given, the path is changed relative to the original current directory. The return value is False on failure, which will happen if the specified directory does not exist.

File/Directory Management

Function CreateDir (DirName: String @) Returns Boolean;
Function DeleteDir (DirName: String @) Returns Boolean;

CreateDir creates a directory. It cannot create multiple nested directories; all but the last directory in the path specified must exist. DeleteDir removes a directory. For this to work, the directory must be completely empty, even of directories and hidden files.

Both functions return True on success and False on failure.

Function FileExists (FileName: String @) Returns Boolean;
Function DirExists () Returns Boolean;

FileExists returns whether the specified file exists and is a file (as opposed to a directory), while DirExists returns whether the specified directory exists.

Function CacheFileInfo (FileName: String @);

This function retrieves information about a particular file or directory.  When the functions below are called immediately afterward on the same file, retrieving information is sped up.  Call this function with an empty filename string to clear the cache.

Enum File Attributes Inherits Integer {
	DoesExist = 1,
	IsDir = 2,
	IsFile = 4,
	IsHidden = 8,
	IsSystem = 16,
	IsReadOnly = 32,
	IsArchive = 64,
}
Function GetAttributes (FileName: String @) Returns File Attributes;

This function retrieves the attributes of a file.

Function GetModifyDate (FileName: String @, Date: Date @) Returns Integer;
Function GetCreationDate (FileName: String @, Date: Date @) Returns Integer;
Function GetAccessDate (FileName: String @, Date: Date @) Returns Integer;

These functions retrieve the dates associated with a file. If the function fails (either because the file does not exist, access is denied, or the file system containing the file does not store the specified date), an error code is returned; True is returned on success.

Function SetModifyDate (FileName: String @, Date: Date @) Returns Integer;
Function SetCreationDate (FileName: String @, Date: Date @) Returns Integer;
Function SetAccessDate (FileName: String @, Date: Date @) Returns Integer;

These functions change the dates associated with a file. True is returned on success, or an error code on failure.

Function Delete (FileName: String) Returns Integer;

Deletes a file. True is returned on success, and an error code on failure. This function cannot be used to delete directories.

Function Rename (FileName: String "[To]" NewName: String) Returns Integer;

This function changes the name of a file or folder, and optionally, for non-folders, move it to another location as well. NewName specifies the new name, and, optionally, the new path. If NewName contains a relative path, the file's current location is used as a base. True is returned on success, and an error code on failure.

Function Move (FileName: String "[To]" NewPath: String) Returns Integer;

This function moves a file. The NewPath must not contain the name of the file, only the destination directory. If NewPath contains a relative path, the file's current location is used as a base. This function cannot move directories. True is returned on success, and an error code on failure.

Function Copy (FileName: String "[To]" NewPath: String) Returns Integer;

This function makes a copy of a file. The copy of the file is given the same attributes and dates as the original file.

On success, True is returned. On failure, an error code is returned. If failure occurs partway through writing the file, Copy will attempt to delete the file before returning an error code.

Enum Access Flags Inherits Integer {
	UserRead = 1,
	UserWrite = 2,
	UserExecute = 4,
	GroupRead = 8,
	GroupWrite = 16,
	GroupExecute = 32,
	OtherRead = 64,
	OtherWrite = 128,
	OtherExecute = 256
};
Function GetAccessFlags (FileName: String @) Returns Access Flags;
Function SetAccessFlags (FileName: String @; Flags: Access Flags) Returns Boolean;

These functions retrieve or set the access flags of a file or folder. GetAccessFlags returns 0 on failure; SetAccessFlags returns False on failure.

Function GetOwner (FileName: String @) Returns String;
Function SetOwner (FileName: String @; NewOwner: String @) Returns Boolean;
Function GetGroup (FileName: String @) Returns String;
Function SetGroup (FileName: String @; NewGroup: String @) Returns Boolean;

These functions get or set the owner or group of a file. GetOwner and GetGroup return "" on failure; SetOwner and SetGroup return False on failure.

 

Table of Contents Qwertie's Site/Mirror
Next
Previous
Hosted by www.Geocities.ws

1