File diff r6178:fc8bd2bde93a → r6179:c0508e7aefec
src/fileio.cpp
Show inline comments
 
/* $Id$ */
 

	
 
/** @file fileio.cpp Standard In/Out file operations*/
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "fileio.h"
 
#include "functions.h"
 
#include "string.h"
 
#include "macros.h"
 
@@ -28,13 +30,13 @@ typedef struct {
 
	uint usage_count[MAX_HANDLES];      ///< count how many times this file has been opened
 
#endif /* LIMITED_FDS */
 
} Fio;
 

	
 
static Fio _fio;
 

	
 
// Get current position in file
 
/* Get current position in file */
 
uint32 FioGetPos(void)
 
{
 
	return _fio.pos + (_fio.buffer - _fio.buffer_start) - FIO_BUFFER_SIZE;
 
}
 

	
 
void FioSeekTo(uint32 pos, int mode)
 
@@ -54,13 +56,13 @@ static void FioRestoreFile(int slot)
 
		FioOpenFile(slot, _fio.filename[slot]);
 
	}
 
	_fio.usage_count[slot]++;
 
}
 
#endif /* LIMITED_FDS */
 

	
 
// Seek to a file and a position
 
/* Seek to a file and a position */
 
void FioSeekToFile(uint32 pos)
 
{
 
	FILE *f;
 
#if defined(LIMITED_FDS)
 
	/* Make sure we have this file open */
 
	FioRestoreFile(pos >> 24);
 
@@ -174,13 +176,13 @@ FILE *FioFOpenFile(const char *filename)
 
#if !defined(WIN32)
 
	if (f == NULL) {
 
		strtolower(buf + strlen(_paths.data_dir) - 1);
 
		f = fopen(buf, "rb");
 

	
 
#if defined SECOND_DATA_DIR
 
		// tries in the 2nd data directory
 
		/* tries in the 2nd data directory */
 
		if (f == NULL) {
 
			snprintf(buf, lengthof(buf), "%s%s", _paths.second_data_dir, filename);
 
			strtolower(buf + strlen(_paths.second_data_dir) - 1);
 
			f = fopen(buf, "rb");
 
		}
 
#endif