Game Development Reference
In-Depth Information
enum FILE_OPERATION
{
FILE_OPEN=0,
FILE_READ,
FILE_READ_COMPLETE,
FILE_SEEK,
FILE_CLOSE
};
// Forward declaration.
struct ReadClash;
class FileEntry
{
public:
FileEntry() : m_opened( false ), m_reading( false ),
m_num_reads( 0 ) {}
void addEntryToClashList( FileEntry * clash_entry );
String m_filename;
bool m_opened;
bool m_reading;
int m_num_reads;
LinkedList< ReadClash * > m_clash_list;
};
// Structure to store any read clashes we find.
struct ReadClash
{
ReadClash() m_clashed_file_entry( null ),
m_num_clashes( 0 ) {}
FileEntry * m_clashed_file_entry;
int
m_num_clashes;
};
void identifyFileReadClashes( )
{
LinkedList< FileEntry* > file_list;
File * log_file = open_file( FileLog.txt );
// Iterate through our log file.
while (!feof( log_file ))
{
String line;
read_line_from_file( line, log_file );
FILE_OPERATION file_op = parse_line( line );
switch ( file_op )
{
case ( FILE_OPEN ):
{
FileEntry * entry;
entry = file_list.find( getFilename( line ) );
// Check if entry is found else create one for
// this file!
if ( entry == null )
{
entry = new FileEntry();
Search WWH ::




Custom Search