Go to the documentation of this file.00001 #ifndef __FILE_ABSTRACTION_H__
00002 #define __FILE_ABSTRACTION_H__
00003
00004 #include <string>
00005
00006 #include <utilities/exception.h>
00007 #include <utilities/nwindows.h>
00008 #include <utilities/testing_utilities.h>
00009
00010 #if !defined( WIN32_PLATFORM ) && !defined( NIX_PLATFORM ) && !defined( MINGW_PLATFORM ) && !defined( CYGWIN_PLATFORM )
00011 #define WIN32_PLATFORM
00012 #endif
00013
00014 #ifdef FILE_ABSTRACTION
00015 #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM ) || defined( CYGWIN_PLATFORM )
00016 #define FILE_ABSTRACTION_DLL_ENTITY __declspec( dllexport )
00017 #endif
00018
00019 #if defined( NIX_PLATFORM )
00020 #define FILE_ABSTRACTION_DLL_ENTITY
00021 #endif
00022 #else
00023 #ifdef WIN32_PLATFORM
00024 #define FILE_ABSTRACTION_DLL_ENTITY __declspec( dllimport )
00025 #pragma comment( lib , "file_abstraction.lib" )
00026 #endif
00027
00028 #if defined( CYGWIN_PLATFORM ) || defined( MINGW_PLATFORM )
00029 #define FILE_ABSTRACTION_DLL_ENTITY __declspec( dllimport )
00030 #endif
00031
00032 #if defined( NIX_PLATFORM )
00033 #define FILE_ABSTRACTION_DLL_ENTITY
00034 #endif
00035 #endif
00036
00037 namespace nitro
00038 {
00049 const std::size_t FA_FILE_BEGIN = 0;
00050
00061 const std::size_t FA_FILE_CURRENT = 1;
00062
00073 const std::size_t FA_FILE_END = 2;
00074
00085 const std::size_t FA_FILE_BINARY = 1;
00086
00101 const std::size_t FA_FILE_TEXT = 2;
00102
00117 const std::size_t FA_FILE_READ = 4;
00118
00133 const std::size_t FA_FILE_WRITE = 8;
00134
00149 const std::size_t FA_FILE_APPEND = 16;
00150
00165 const std::size_t FA_FILE_TRUNCATE = 32;
00166
00179 class FILE_ABSTRACTION_DLL_ENTITY FileAbstraction{
00180
00181 public:
00182
00193 FileAbstraction( void );
00194
00217 void Open( const char * FilePath , const std::size_t theMode );
00218 ALIAS_FUNCTION_2( Open , aliasOpen , const char * , std::size_t );
00219
00242 void Open( const std::string & FilePath , const std::size_t Mode );
00243
00266 void Seek( std::size_t Offset , std::size_t theMode );
00267
00286 std::size_t Tell( void );
00287
00310 void Write( const char * Buffer , std::size_t BufferLength );
00311
00338 std::size_t Read( char * Buffer , std::size_t BufferLength );
00339
00354 void Close( void );
00355
00366 virtual ~FileAbstraction();
00367
00386 static void DeleteFile( const char * FilePath );
00387
00407 static void DeleteFile( const std::string & FilePath );
00408
00431 static void RenameFile( const char * FilePathFrom , const char * FilePathTo );
00432
00455 static void RenameFile( const std::string & FilePathFrom , const std::string & FilePathTo );
00456
00479 static int GetOwner( const std::string & FilePath );
00480
00503 static int GetGroup( const std::string & FilePath );
00504
00505 private:
00506
00517 std::size_t Mode;
00518
00529 void * FileData;
00530
00541 FileAbstraction( const FileAbstraction & ){}
00542
00553 FileAbstraction operator=( const FileAbstraction & ){return( *this );};
00554 };
00555
00556 ALIAS_FUNCTION_1( FileAbstraction::DeleteFile , aliasDeleteFile , const char * );
00557 ALIAS_FUNCTION_2( FileAbstraction::RenameFile , aliasRenameFile , const char * , const char * );
00558
00559 }
00560
00561 #endif