/******************************************************************************
 * $LastChangedDate: 2011-04-23 21:07:07 -0400 (Sat, 23 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   File functions.
 *//*
 * LEGAL:   COPYRIGHT (C) 2004 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 ******************************************************************************/

#ifndef BASE_FILE_HH
#define BASE_FILE_HH 1

#include <utility>
#include <vector>
#include "base/misc.hh"
#include "base/stringbuf.hh"
#include "base/sys_file.hh"

namespace base {

// Maximum pathname length (MAX_PATH is reserved).
const uint BASE_MAX_PATH = 256;

bool
IfFileExists( const string& fname );

long
FileSize( FILE* file );

long
FileSize( const string& fname );

bool
ReadFile( const string& fname, string& obuf );

bool
ReadFile( const string& fname, StringBuf& strbuf );

#if COMPILE_ZLIB
// C++ streams for zlib are at base/stream_zlib.hh
bool
ReadFileGzipIntoString( const string& fname, string& obuf, const uint chunkLen = 256*1024 );

std::pair<void*,long>
ReadFileGzipIntoMemory( const string& fname );
#endif

bool
RemoveFile( const string& fname );

void
RemoveSuffix( string& fname/*IN/OUT*/, const string& suffix );

bool
IfPathIsAbsolute( const string& path );

bool
IfPathIsFilename( const string& path );

string
FileBasename( const string& path );

bool
MakeDir( const string& path );  // mkdir

bool
IfDirExists( const string& dirname );

bool
FilesInDir( const string& dirname, std::vector<string>& vec /*OUT*/ );

string
GetCwd( void );

} // namespace base

#endif /* BASE_FILE_HH */
