v0.1.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Pages
CGUL::File Namespace Reference

A simple file utility. More...

Functions

Boolean WriteText (const String &fileName, String string)
 
Boolean WriteData (const String &fileName, Byte *buffer, UInt32 size)
 
void ReadText (const String &fileName, String *result)
 Puts the file contents into a string. More...
 
void ReadLines (const String &fileName, std::vector< String > *vector)
 Reads the contents of the file line-by-line, putting each line into a vector one-by-one. More...
 
void ReadData (const String &fileName, Byte *buffer, UInt32 size)
 Reads the file into a byte buffer. More...
 
Boolean GetFileSize (const String &fileName, UInt32 *fileSize)
 Obtains the size of a file. More...
 
UInt32 GetFileSize (const String &fileName)
 Obtains the size of a file. More...
 
void FindFiles (const String &path, FixedList< String > *files)
 
void FindDirectories (const String &path, FixedList< String > *directories)
 
Boolean Exists (const String &fileName)
 Checks if a file exists. More...
 
Enum GetAccess (const String &fileName)
 Checks the permissions on a file. More...
 
UInt32 CRC32 (const String &fileName)
 
String MD5 (const String &fileName)
 
Boolean IsDirectory (const String &fileName)
 Checks if the specified filename is a directory. More...
 
Boolean IsFile (const String &fileName)
 Checks if the specified filename is a file. More...
 
Boolean CreateDirectory (const String &fileName, bool recursive=false)
 
Boolean DeleteDirectory (const String &fileName, bool recursive=false)
 
Boolean DeleteFile (const String &fileName)
 Deletes the specified file. More...
 
Boolean Copy (const String &fileName, const String &fileTo)
 Copies a file from one location to another. More...
 
Boolean Move (const String &fileName, const String &fileTo)
 Moves a file from one location to another. More...
 

Detailed Description

A simple file utility.

Function Documentation

CGUL::Boolean CGUL::File::Copy ( const String &  fileName,
const String &  fileTo 
)

Copies a file from one location to another.

Parameters
fileNameThe target file.
fileToThe destination file.
Returns
True if the file was successfully copied, false otherwise.
CGUL::Boolean CGUL::File::DeleteFile ( const String &  fileName)

Deletes the specified file.

Parameters
fileNameThe file to delete.
Returns
True if the file was successfully deleted, false otherwise.
CGUL::Boolean CGUL::File::Exists ( const String &  fileName)

Checks if a file exists.

Parameters
fileNameThe name of the file to check for.
Returns
True if the file exists, false otherwise.
CGUL::Enum CGUL::File::GetAccess ( const String &  fileName)

Checks the permissions on a file.

Determines the READ, WRITE, and EXECUTE permissions of the current user for the given file. Simply checking if a file exists is not enough information to know if that file can be operated on.

CGUL::Boolean CGUL::File::GetFileSize ( const String &  fileName,
UInt32 *  fileSize 
)

Obtains the size of a file.

Parameters
fileNameThe file to get the size of.
fileSizeA pointer to an integer to put the size into.
Returns
True if the size was successfully obtained, false otherwise.
CGUL::UInt32 CGUL::File::GetFileSize ( const String &  fileName)

Obtains the size of a file.

Parameters
fileNameThe file to get the size of.
Returns
The size of the file, or 0 if the size could not be obtained.
Note
There is a conflict in logic if a file is empty or if it does not exist. Both cases will return 0. Consider using the other GetFileSize function which returns a boolean value if the size was successfully obtained.
CGUL::Boolean CGUL::File::IsDirectory ( const String &  fileName)

Checks if the specified filename is a directory.

Parameters
fileNameThe filename to check.
Returns
True if the filename is a directory, false otherwise.
CGUL::Boolean CGUL::File::IsFile ( const String &  fileName)

Checks if the specified filename is a file.

Parameters
fileNameThe filename to check.
Returns
True if the filename is a file, false otherwise.
CGUL::Boolean CGUL::File::Move ( const String &  fileName,
const String &  fileTo 
)

Moves a file from one location to another.

Parameters
fileNameThe target file.
fileToThe destination file.
Returns
True if the file was successfully moved, false otherwise.
void CGUL::File::ReadData ( const String &  fileName,
Byte *  buffer,
UInt32  size 
)

Reads the file into a byte buffer.

Parameters
fileNameThe file to read.
bufferThe buffer to copy the bytes into.
sizeThe size of the buffer or the max amount of bytes to read.
void CGUL::File::ReadLines ( const String &  fileName,
std::vector< String > *  vector 
)

Reads the contents of the file line-by-line, putting each line into a vector one-by-one.

Parameters
fileNameThe file to read. A pointer to the vector to append the lines to.
void CGUL::File::ReadText ( const String &  fileName,
CGUL::String result 
)

Puts the file contents into a string.

Parameters
fileNameThe file to read.
resultA pointer to the string to append the data to.