File

Functions for dealing with file IO and manipulation.

FileExists
Check if a file exists.
FixFilename
Make sure a file path is properly formatted (has a single "\" between parts).
GetIFLfiles
Get a list of files pointed to by an IFL file.
GetParentDir
Get a directory's or filename's parent directory.
GetSequences
Get an array of all file sequences in directory.
GetSequenceFilenameBase
Get the base filename of a file sequence.
GetSubDirs
Get a directory tree, to a specified depth.
IsBitmapFile
Checks if file is a valid bitmap.
IsFileCreateNewer
Checks if file A's create time is more recent than file B's.
IsFileModNewer
Checks if file A's modify time is more recent than file B's.
IsFileType
Checks if filename is a certain type.
IsSequenceFile
Checks if file is _potentially_ part of a file sequence.
IsUNCpath
Simple check to see if fPath is a UNC path.
IsValidFilename
Check to see if a string would be a valid filename (ie. doesn't contain illegal characters).
MakeIFL
Create an IFL from an array of filenames (with paths).
SortINISection
Sort the keys in an section of an INI file for easier reading.

FileExists:

Check if a file exists.

Returns:

True if file exits, false otherwise.

Arguments:
<filename>
Full path and filename of the file be checked for.

Back to top...


FixFilename:

Make sure a file path is properly formatted (has a single "\" between parts).

Returns:

Fixed filename.

Arguments:
<filename>
Filename/path string that needs to be fixed.

Back to top...


GetIFLfiles:

Get a list of files pointed to by an IFL file.
Currently works only if the IFL is in the same directory as the files listed within it.

Returns:

Returns an array of full filename strings present in an IFL, or undefined on failure.

Arguments:
<IFLfile>
Full path and filename of the IFL to look at.

Back to top...


GetParentDir:

Get a directory's or filename's parent directory.

Returns:

The parent directory of the given file.

Arguments:
<filename>
The full path and filename of the filename to check.

Back to top...


GetSequences:

Get an array of all file sequences in directory.

Returns:

An array of arrays (or an empty array if no sequences found).
Each sub-array represents a sequence found, and contains a list of files in the sequence. ie:
#(#(foo01.tga, foo02.tga, foo03.tga),#(bar01.tga, ..., bar50.tga))

Arguments:
<dirName>
The directory to look in for sequences.

Back to top...


GetSequenceFilenameBase:

Get the base filename of a file sequence.

Returns:

Returns the base name (no path or extention) of a sequence filename, or the original filename if file isn't part of a sequence.

Arguments:
<filename>
The file to check whether it is part of a sequence or not.

Back to top...


GetSubDirs:

Get a directory tree, to a specified depth.

Returns:

An array of subdirectory paths.

Arguments:
<dirName>
The directory to look for subdirs in
[depth:-1]
How deep to recurse into the subdirectories.
-1 will get all subdirectories
1 will only look for immediate subdirs
2 will include the subdirs of the immediate subdirs, etc..
[subDirs:#()]
An array to store the subDirs in.

Back to top...


IsBitmapFile:

Checks if filename is a valid bitmap.

Returns:

True if file is a bitmap, otherwise false.

Arguments:
<filename>
The path and filename of the file to check.

Back to top...


IsFileCreateNewer:

Checks if file A's create time is more recent than file B's.

Returns:

True if file A was created after file B, false if opposite, or undefined on failure.

Arguments:
<filenameA>
The path and filename of the file to compare.
<filenameB>
The path and filename of the file to compare.

Back to top...


IsFileModNewer:

Checks if file A's modify time is more recent than file B's.

Returns:

True if file A was modified after file B, false if opposite, or undefined on failure.

Arguments:
<filenameA>
The path and filename of the file to compare.
<filenameB>
The path and filename of the file to compare.

Back to top...


IsFileType:

Checks if filename is a certain type.

Returns:

True if filename is the given type, otherwise false.
(Note: the check is case insensitive. ie: IsFileType "foo.tga" "TGA" returns true).

Arguments:
<filename>
Full path and filename of the file to check.
<fileType>
Extention of the filetype to check against.

Back to top...


IsSequenceFile:

Checks if file is _potentially_ part of a file sequence (ie. has trailing numbers on filename).

Returns:

True if file may be part of a sequence, otherwise false.

Arguments:
<filename>
Full path and filename of the file to check.

Back to top...


IsUNCpath:

Simple check to see if fPath is a UNC path.

Returns:

True if filename is a UNC path, otherwise false.

Arguments:
<filename>
Full path and filename of the file to check.

Back to top...


IsValidFilename:

Check to see if a string would be a valid filename (ie. doesn't contain illegal characters).

Returns:

True if filename is valid, otherwise false.

Arguments:
<filename>
Filename (with optional extention) to check.

Back to top...


MakeIFL:

Create an IFL from an array of filenames (with paths).

Returns:

The filename of the created IFL file, or undefined on failure.

Arguments:
<filenameArray>
Array of filenames to include in IFL file (this will be sorted automatically).
[filename:undefined]
The filename of the IFL file to create. If undefined, the filename will be automatically generated based on the passed file sequence.
[includePath:false]
If true, then the IFL will include pathnames for each file in the IFL.
[createInParent:false]
If true, then the IFL will be created in the parent directory of the file sequence. This option forces the IFL to use relative paths.

Back to top...


SortINISection:

Sort the keys in an section of an INI file for easier reading. It assumes the section has a set of keys that share a common "base name" with a sequence number appended. ie:

[Section]
Key1=foo
Key2=bar
Key3=ack
Key4=nack
Calling SortINISection myINIfile "Section" "Key" 4 will result in the section looking like:
[Section]
Key1=ack
Key2=bar
Key3=foo
Key4=nack

Returns:

TRUE on sucess, otherwise FALSE.

Arguments:
<INIfile>
The INI file to sort.
<sectionName>
The section of the INI file to sort.
<keyNameBase>
The "base name" of the keys to sort.
<count>
How many keys are in the section you want to sort.

Back to top...