Angel 3.2
A 2D Game Prototyping Engine
Functions
FileUtil.h File Reference
#include "../Util/StringUtil.h"

Go to the source code of this file.

Functions

bool GetLinesFromFile (const String &fileName, StringList &outList)
 
bool WriteLinesToFile (const String &fileName, const StringList &strings)
 
bool AppendLineToFile (const String &fileName, const String &line)
 
bool MakeDirectories (const String &path)
 
const String ReadWholeFile (const String &fileName)
 
const String GetStorageDirectory ()
 
const String GetDocumentsPath ()
 
const String GetExeName ()
 
const long GetModificationTime (const String &fileName)
 

Detailed Description

A set of C-style utility functions to handle reading and writing files.

Definition in file FileUtil.h.

Function Documentation

bool GetLinesFromFile ( const String &  fileName,
StringList &  outList 
)

Gets the entire contents of a file with each line separated for you. (Doesn't do smart streaming, so don't pass it bajigabyte sized files.)

Parameters
fileNameThe path to the file to load
outListA StringList to which the file's lines will be appended, with each line being its own value.
Returns
True if we could read the file, false if we couldn't

Definition at line 50 of file FileUtil.cpp.

bool WriteLinesToFile ( const String &  fileName,
const StringList &  strings 
)

Writes a set of lines to a file. Will wipe out any existing file contents.

Parameters
fileNameThe path of the file to write to
stringsThe StringList to be written (each string will get its own line)
Returns
True if we could write to the file, false if we couldn't

Definition at line 80 of file FileUtil.cpp.

bool AppendLineToFile ( const String &  fileName,
const String &  line 
)

Appends a set of lines to a file.

Parameters
fileNameThe path of the file to append to
stringsThe StringList to be append (each string will get its own line)
Returns
True if we could write to the file, false if we couldn't

Definition at line 95 of file FileUtil.cpp.

bool MakeDirectories ( const String &  path)

Ensures that a path of directories exists – returns true if it does, false if it doesn't (if, for example, the program doesn't have sufficient permissions to create the path).

Parameters
pathThe path to create
Returns
Whether it actually exists at the end of this function

Definition at line 107 of file FileUtil.cpp.

const String ReadWholeFile ( const String &  fileName)

Convenience function for reading an entire file as a single string. If there is no such file, and empty string will be returned.

Parameters
fileNameThe file to read
Returns
The complete text of the file

Definition at line 68 of file FileUtil.cpp.

const String GetStorageDirectory ( )

Gives a system-appropriate writable directory for the use of logs, preference files, etc.

Returns
The path to the defined writable directory.

Definition at line 157 of file FileUtil.cpp.

const String GetDocumentsPath ( )

Returns a path to the My Documents directory on Windows, or the ~/Documents folder on Mac. On Linux? Who knows?!

Returns
Path to the user's documents

Definition at line 180 of file FileUtil.cpp.

const String GetExeName ( )

Gives the name of the current executable.

Returns
The name of the current executable

Definition at line 203 of file FileUtil.cpp.

const long GetModificationTime ( const String &  fileName)

Returns the modification time of a file. Defined as number of seconds after a system-specific epoch, so not portable between operating systems, but useful for comparisons within a single build.

Parameters
fileNameThe file to check
Returns
The modification time of the file. Returns 0 if file could not be found. NOTE: this actually is a valid modification time, so apologies if you happen to have a file that was modified exactly on your epoch time.

Definition at line 240 of file FileUtil.cpp.