Main   Class List   Namespace List   Wiki

File I/O
[Core]

Functions allowing you to search for files, read them, write them, and access their properties. More...

Classes

class  FileDialog
 Base class responsible for displaying an OS file browser. More...
class  FileObject
 This class is responsible opening, reading, creating, and saving file contents. More...
class  FileStreamObject
 A wrapper around StreamObject for parsing text and data from files. More...
class  OpenFileDialog
 Derived from FileDialog, this class is responsible for opening a file browser with the intention of opening a file. More...
class  OpenFolderDialog
 OS level dialog used for browsing folder structures. More...
class  SaveFileDialog
 Derived from FileDialog, this class is responsible for opening a file browser with the intention of saving a file. More...
class  SimXMLDocument
 File I/O object used for creating, reading, and writing XML documents. More...
class  StreamObject
 Base class for working with streams. More...
class  ZipObject
 Provides access to a zip file. More...

Modules

 File Searching
 

Functions for searching files by name patterns.


Functions

bool createPath (string path)
 Create the given directory or the path leading to the given filename.
string expandFilename (string filename)
 Grabs the full path of a specified file.
string expandOldFilename (string filename)
 Retrofits a filepath that uses old Torque style.
String fileBase (string fileName)
 Get the base of a file name (removes extension).
String fileCreatedTime (string fileName)
 Returns a platform specific formatted string with the creation time for the file.
bool fileDelete (string path)
 Delete a file from the hard drive.
String fileExt (string fileName)
 Get the extension of a file.
String fileModifiedTime (string fileName)
 Returns a platform specific formatted string with the last modified time for the file.
String fileName (string fileName)
 Get the file name of a file (removes extension and path).
String filePath (string fileName)
 Get the path of a file (removes name and extension).
int fileSize (string fileName)
 Determines the size of a file on disk.
String getCurrentDirectory ()
 Return the current working directory.
String getDirectoryList (string path, int depth=0)
 Gathers a list of directories starting at the given path.
String getExecutableName ()
 Gets the name of the game's executable.
int getFileCRC (string fileName)
 Provides the CRC checksum of the given file.
String getMainDotCsDir ()
 Get the absolute path to the directory that contains the main.cs script from which the engine was started.
String getWorkingDirectory ()
 Reports the current directory.
bool IsDirectory (string directory)
 Determines if a specified directory exists or not.
bool isFile (string fileName)
 Determines if the specified file exists or not.
bool isWriteableFileName (string fileName)
 Determines if a file name can be written to using File I/O.
String makeFullPath (string path, string cwd="")
 Converts a relative file path to a full path.
String makeRelativePath (string path, string to="")
 Turns a full or local path to a relative one.
void openFile (string file)
 Open the given file through the system. This will usually open the file in its associated application.
void openFolder (string path)
 Open the given folder in the system's file manager.
String pathConcat (string path, string file)
 Combines two separate strings containing a file path and file name together into a single string.
bool pathCopy (string fromFile, string toFile, bool noOverwrite=true)
 Copy a file to a new location.
bool setCurrentDirectory (string path)
 Set the current working directory.
void startFileChangeNotifications ()
 Start watching resources for file changes.
void stopFileChangeNotifications ()
 Stop watching resources for file changes.

Variables

string $Con::File
 The currently executing script file.
string $Con::Root
 The mod folder for the currently executing script file.

Detailed Description

Functions allowing you to search for files, read them, write them, and access their properties.


Function Documentation

bool createPath ( string  path  ) 

Create the given directory or the path leading to the given filename.

If path ends in a trailing slash, then all components in the given path will be created as directories (if not already in place). If path, does not end in a trailing slash, then the last component of the path is taken to be a file name and only the directory components of the path will be created.

Parameters:
path The path to create.
Note:
Only present in a Tools build of Torque.
string expandFilename ( string  filename  ) 

Grabs the full path of a specified file.

Parameters:
filename Name of the local file to locate
Returns:
String containing the full filepath on disk
string expandOldFilename ( string  filename  ) 

Retrofits a filepath that uses old Torque style.

Returns:
String containing filepath with new formatting
String fileBase ( string  fileName  ) 

Get the base of a file name (removes extension).

Parameters:
fileName Name and path of file to check
Returns:
String containing the file name, minus extension
String fileCreatedTime ( string  fileName  ) 

Returns a platform specific formatted string with the creation time for the file.

Parameters:
fileName Name and path of file to check
Returns:
Formatted string (OS specific) containing created time, "9/3/2010 12:33:47 PM" for example
bool fileDelete ( string  path  ) 

Delete a file from the hard drive.

Parameters:
path Name and path of the file to delete
Note:
THERE IS NO RECOVERY FROM THIS. Deleted file is gone for good.
Returns:
True if file was successfully deleted
String fileExt ( string  fileName  ) 

Get the extension of a file.

Parameters:
fileName Name and path of file
Returns:
String containing the extension, such as ".exe" or ".cs"
String fileModifiedTime ( string  fileName  ) 

Returns a platform specific formatted string with the last modified time for the file.

Parameters:
fileName Name and path of file to check
Returns:
Formatted string (OS specific) containing modified time, "9/3/2010 12:33:47 PM" for example
String fileName ( string  fileName  ) 

Get the file name of a file (removes extension and path).

Parameters:
fileName Name and path of file to check
Returns:
String containing the file name, minus extension and path
String filePath ( string  fileName  ) 

Get the path of a file (removes name and extension).

Parameters:
fileName Name and path of file to check
Returns:
String containing the path, minus name and extension
int fileSize ( string  fileName  ) 

Determines the size of a file on disk.

Parameters:
fileName Name and path of the file to check
Returns:
Returns filesize in KB, or -1 if no file
String getCurrentDirectory (  ) 

Return the current working directory.

Returns:
The absolute path of the current working directory.
Note:
Only present in a Tools build of Torque.
See also:
getWorkingDirectory()
String getDirectoryList ( string  path,
int  depth = 0 
)

Gathers a list of directories starting at the given path.

Parameters:
path String containing the path of the directory
depth Depth of search, as in how many subdirectories to parse through
Returns:
Tab delimited string containing list of directories found during search, "" if no files were found
String getExecutableName (  ) 

Gets the name of the game's executable.

Returns:
String containing this game's executable name
int getFileCRC ( string  fileName  ) 

Provides the CRC checksum of the given file.

Parameters:
fileName The path to the file.
Returns:
The calculated CRC checksum of the file, or -1 if the file could not be found.
String getMainDotCsDir (  ) 

Get the absolute path to the directory that contains the main.cs script from which the engine was started.

This directory will usually contain all the game assets and, in a user-side game installation, will usually be read-only.

Returns:
The path to the main game assets.
String getWorkingDirectory (  ) 

Reports the current directory.

Returns:
String containing full file path of working directory
bool IsDirectory ( string  directory  ) 

Determines if a specified directory exists or not.

Parameters:
directory String containing path in the form of "foo/bar"
Returns:
Returns true if the directory was found.
Note:
Do not include a trailing slash '/'.
bool isFile ( string  fileName  ) 

Determines if the specified file exists or not.

Parameters:
fileName The path to the file.
Returns:
Returns true if the file was found.
bool isWriteableFileName ( string  fileName  ) 

Determines if a file name can be written to using File I/O.

Parameters:
fileName Name and path of file to check
Returns:
Returns true if the file can be written to.
String makeFullPath ( string  path,
string  cwd = "" 
)

Converts a relative file path to a full path.

For example, "./console.log" becomes "C:/Torque/t3d/examples/FPS Example/game/console.log"

Parameters:
path Name of file or path to check
cwd Optional current working directory from which to build the full path.
Returns:
String containing non-relative directory of path
String makeRelativePath ( string  path,
string  to = "" 
)

Turns a full or local path to a relative one.

For example, "./game/art" becomes "game/art"

Parameters:
path Full path (may include a file) to convert
to Optional base path used for the conversion. If not supplied the current working directory is used.
Returns:
String containing relative path
void openFile ( string  file  ) 

Open the given file through the system. This will usually open the file in its associated application.

Parameters:
file Path of the file to open.
Note:
Only present in a Tools build of Torque.
void openFolder ( string  path  ) 

Open the given folder in the system's file manager.

Parameters:
path full path to a directory.
Note:
Only present in a Tools build of Torque.
String pathConcat ( string  path,
string  file 
)

Combines two separate strings containing a file path and file name together into a single string.

Parameters:
path String containing file path
file String containing file name
Returns:
String containing concatenated file name and path
bool pathCopy ( string  fromFile,
string  toFile,
bool  noOverwrite = true 
)

Copy a file to a new location.

Parameters:
fromFile Path of the file to copy.
toFile Path where to copy fromFile to.
noOverwrite If true, then fromFile will not overwrite a file that may already exist at toFile.
Returns:
True if the file was successfully copied, false otherwise.
Note:
Only present in a Tools build of Torque.
bool setCurrentDirectory ( string  path  ) 

Set the current working directory.

Parameters:
path The absolute or relative (to the current working directory) path of the directory which should be made the new working directory.
Returns:
True if the working directory was successfully changed to path, false otherwise.
Note:
Only present in a Tools build of Torque.
void startFileChangeNotifications (  ) 

Start watching resources for file changes.

Typically this is called during initializeCore().

See also:
stopFileChangeNotifications()
void stopFileChangeNotifications (  ) 

Stop watching resources for file changes.

Typically this is called during shutdownCore().

See also:
startFileChangeNotifications()

Variable Documentation

string $Con::File

The currently executing script file.

string $Con::Root

The mod folder for the currently executing script file.



Copyright © GarageGames, LLC. All Rights Reserved.