Открытые члены | Открытые статические члены | Закрытые члены | Закрытые данные

Класс nitro::FileAbstraction

Класс, предоставляющий кроссплатформенный АПИ для работы с файлами. Подробнее...

#include <system/file_abstraction.h>

Производные классы:nitro::File.

Полный список членов класса

Открытые члены

 FileAbstraction (void)
void Open (const char *FilePath, const std::size_t theMode)
 ALIAS_FUNCTION_2 (Open, aliasOpen, const char *, std::size_t)
void Open (const std::string &FilePath, const std::size_t Mode)
void Seek (std::size_t Offset, std::size_t theMode)
std::size_t Tell (void)
void Write (const char *Buffer, std::size_t BufferLength)
std::size_t Read (char *Buffer, std::size_t BufferLength)
void Close (void)
virtual ~FileAbstraction ()

Открытые статические члены

static void DeleteFile (const char *FilePath)
static void DeleteFile (const std::string &FilePath)
static void RenameFile (const char *FilePathFrom, const char *FilePathTo)
static void RenameFile (const std::string &FilePathFrom, const std::string &FilePathTo)
static int GetOwner (const std::string &FilePath)
static int GetGroup (const std::string &FilePath)

Закрытые члены

 FileAbstraction (const FileAbstraction &)
FileAbstraction operator= (const FileAbstraction &)

Закрытые данные

std::size_t Mode
void * FileData

Подробное описание

Класс, предоставляющий кроссплатформенный АПИ для работы с файлами.

Автор:
Додонов А.А.

См. определение в файле file_abstraction.h строка 179


Конструктор(ы)

nitro::FileAbstraction::FileAbstraction ( void   ) 

Конструктор по-умолчанию.

Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 19

Перекрестные ссылки FileData.

        {
                FileData = NULL;
        }

nitro::FileAbstraction::~FileAbstraction (  )  [virtual]

Деструктор (виртуальный).

Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 344

Перекрестные ссылки Close().

        {
                try
                {
                        Close();
                }
                catch( ... )
                {
                }
        }

Граф вызовов:

nitro::FileAbstraction::FileAbstraction ( const FileAbstraction  )  [inline, private]

Закрытый конструктор копирования.

Автор:
Додонов А.А.

См. определение в файле file_abstraction.h строка 541

{}


Методы

nitro::FileAbstraction::ALIAS_FUNCTION_2 ( Open  ,
aliasOpen  ,
const char *  ,
std::size_t   
)
void nitro::FileAbstraction::Close ( void   ) 

Функция закрытия файла.

Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 315

Перекрестные ссылки nitro::exception::code(), FileData и nitro::exception::what().

Используется в nitro::UnTARAbstraction::CloseFile(), nitro::CSVFile::CloseFile(), Open(), nitro::LogStream::Release() и ~FileAbstraction().

        {
                try
                {
                        if( FileData )
                        {
                        #if     defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                                CloseHandle( * ( ( HANDLE * )FileData ) );

                                delete ( HANDLE * ) FileData;
                        #endif

                        #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                                fclose( ( FILE * )FileData );
                        #endif

                                FileData = NULL;
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Close( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Close( void )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

void nitro::FileAbstraction::DeleteFile ( const char *  FilePath  )  [static]

Функция удаления файла.

Аргументы:
FilePath - Путь к удаляемому файлу.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 355

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

Используется в DeleteFile().

        {
                try
                {
                #if     defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        if( ::DeleteFileA( FilePath ) == 0 )
                        {
                                throw( nitro::exception( std::string( "An error occured while deleting file " ) + FilePath , 0 ) );
                        }
                #endif
                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        if( unlink( FilePath ) != 0 )
                        {
                                throw( nitro::exception( std::string( "An error occured while deleting file " ) + FilePath , 0 ) );
                        }
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::DeleteFile( const char * FilePath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::DeleteFile( const char * FilePath )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

void nitro::FileAbstraction::DeleteFile ( const std::string &  FilePath  )  [static]

Функция удаления файла.

Аргументы:
FilePath - Путь к удаляемому файлу.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А. Додонов А.А.

См. определение в файле file_abstraction.cpp строка 425

Перекрестные ссылки nitro::exception::code(), DeleteFile() и nitro::exception::what().

        {
                try
                {
                        DeleteFile( FilePath.c_str() );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::DeleteFile( const std::string & FilePath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::DeleteFile( const std::string & FilePath )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

int nitro::FileAbstraction::GetGroup ( const std::string &  FilePath  )  [static]

Функция получения группы файла.

Аргументы:
FilePath - Путь к файлу.
Возвращает:
Идентификатор группы.
Исключения:
nitro::exception Кидает исключение этого типа с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 489

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                #if     defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        struct _stat    s;
                        int                             Result( _stat( Path.c_str() , & s ) );
                #endif
                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        struct stat             s;
                        int                             Result( stat( Path.c_str() , & s ) );
                #endif

                        if( Result == 0 )
                        {
                                return( s.st_gid );
                        }
                        else
                        {
                                throw( nitro::exception( "Path does not exists" , 0 ) );
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::GetGroup( const std::string & Path )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::GetGroup( const std::string & Path )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

int nitro::FileAbstraction::GetOwner ( const std::string &  FilePath  )  [static]

Функция получения владельца файла.

Аргументы:
FilePath - Путь к файлу.
Возвращает:
Идентификатор пользователя.
Исключения:
nitro::exception Кидает исключение этого типа с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 457

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

        {
                try
                {
                #if     defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        struct _stat    s;
                        int                             Result( _stat( Path.c_str() , & s ) );
                #endif
                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        struct stat             s;
                        int                             Result( stat( Path.c_str() , & s ) );
                #endif

                        if( Result == 0 )
                        {
                                return( s.st_uid );
                        }
                        else
                        {
                                throw( nitro::exception( "Path does not exists" , 0 ) );
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::GetOwner( const std::string & Path )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::GetOwner( const std::string & Path )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

void nitro::FileAbstraction::Open ( const char *  FilePath,
const std::size_t  theMode 
)

Открытие файла по пути FilePath в режиме Mode.

Аргументы:
FilePath - Путь к открываемому файлу.
theMode - Режим работы с файлом.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 24

Перекрестные ссылки Close(), nitro::exception::code(), nitro::FA_FILE_APPEND, nitro::FA_FILE_BEGIN, nitro::FA_FILE_END, nitro::FA_FILE_READ, nitro::FA_FILE_TRUNCATE, nitro::FA_FILE_WRITE, FileData, Mode, Seek() и nitro::exception::what().

Используется в nitro::File::File(), nitro::File::LoadBinDataFromFile(), Open(), nitro::UnTARAbstraction::OpenFile(), nitro::CSVFile::OpenFile(), nitro::LogStream::Reset(), nitro::File::SaveBinDataToFile(), nitro::XMLFile::SaveXML() и nitro::UnZIPAbstraction::UnZIPFile().

        {
                try
                {
                        Close();
                        
                        Mode = theMode;

                        if( !( Mode & FA_FILE_READ ) && !( Mode & FA_FILE_WRITE ) )
                        {
                                // ни чтение ни запись - ошибка.
                                // neither reading nor writing - error
                                throw( nitro::exception( "Neither reading nor writing modes specified - error" , 1 ) );
                        }

                #if     defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        FileData = ( void * ) new HANDLE();

                        unsigned int            Access( 0 );

                        if( Mode & FA_FILE_READ )               Access |= GENERIC_READ;
                        if( Mode & FA_FILE_WRITE )              Access |= GENERIC_WRITE;
                        if( Mode & FA_FILE_APPEND )             Access |= GENERIC_WRITE;

                        unsigned int            Creation( 0 );

                        if( Mode & FA_FILE_READ && Mode & FA_FILE_WRITE )
                        {
                                Creation |= OPEN_ALWAYS;
                        }
                        else
                        {
                                if( Mode & FA_FILE_READ )               Creation |= OPEN_EXISTING;
                                if( Mode & FA_FILE_WRITE )              Creation |= OPEN_ALWAYS;
                        }

                        if( Mode & FA_FILE_TRUNCATE )
                        {
                                // file must exist to be truncated
                                std::ifstream   file( FilePath );
                                if( file.good() )
                                {
                                        Creation |= TRUNCATE_EXISTING;
                                }
                        }

                        * ( ( HANDLE * )FileData ) = CreateFile( FilePath , Access , ( DWORD )NULL , NULL , Creation , ( DWORD )NULL , NULL );

                        if( * ( ( HANDLE * )FileData ) == INVALID_HANDLE_VALUE )
                        {
                                throw( nitro::exception( std::string( "An error occured while opening file " ) + FilePath , 1 ) );
                        }
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )

                        std::string             PlatformMode( "" );

                        if( Mode & FA_FILE_READ && Mode & FA_FILE_WRITE )
                        {
                                // чтение и запись одновременно
                                // both reading and writing
                                if( Mode & FA_FILE_TRUNCATE )
                                {
                                        PlatformMode += "w+";
                                }
                                else
                                {
                                        PlatformMode += "a+";
                                }
                        }

                        if( Mode & FA_FILE_READ && !( Mode & FA_FILE_WRITE ) )
                        {
                                // только чтение
                                // read only
                                PlatformMode += "r";
                        }

                        if( !( Mode & FA_FILE_READ ) && Mode & FA_FILE_WRITE )
                        {
                                // только запись
                                // writing only
                                if( Mode & FA_FILE_TRUNCATE )
                                {
                                        PlatformMode += "w";
                                }
                                else
                                {
                                        std::ifstream   file( FilePath );
                                        
                                        if( file.good() )
                                        {
                                                // открываем уже существующий файл
                                                // opening already existing file
                                                PlatformMode += "r+";
                                        }
                                        else
                                        {
                                                // открываем несуществующий файл
                                                // opening not existing file
                                                PlatformMode += "w";
                                        }
                                }
                        }

                        PlatformMode += "b";

                        FileData = ( void * )fopen( FilePath , PlatformMode.c_str() );

                        if( FileData == NULL )
                        {
                                throw( nitro::exception( std::string( "An error occured while opening file " ) + FilePath , 1 ) );
                        }

                #endif

                        // типа если открыт в режиме добавления, то устанавливаем курсор в конец
                        if( Mode & FA_FILE_APPEND )
                        {
                                Seek( 0 , FA_FILE_END );
                        }
                        else
                        {
                                Seek( 0 , FA_FILE_BEGIN );
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Open( const char * FilePath , const std::size_t theMode )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Open( const char * FilePath , const std::size_t theMode )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

void nitro::FileAbstraction::Open ( const std::string &  FilePath,
const std::size_t  Mode 
)

Открытие файла по пути FilePath в режиме Mode.

Аргументы:
FilePath - Путь к открываемому файлу.
Mode - Режим открываемого файла.
Исключения:
nitro::exception Кидает исключение этого типа с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 409

Перекрестные ссылки nitro::exception::code(), Open() и nitro::exception::what().

        {
                try
                {
                        Open( FilePath.c_str() , theMode );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Open( const std::string & FilePath , const std::size_t theMode )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Open( const std::string & FilePath , const std::size_t theMode )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

FileAbstraction nitro::FileAbstraction::operator= ( const FileAbstraction  )  [inline, private]

Закрытый оператор копирования.

Автор:
одонов А.А.

См. определение в файле file_abstraction.h строка 553

{return( *this );};

std::size_t nitro::FileAbstraction::Read ( char *  Buffer,
std::size_t  BufferLength 
)

Функция чтения бинарных данных в буффер.

Аргументы:
Buffer - Буффер данных.
BufferLength - Длина буффера данных.
Возвращает:
Количество прочитанных байт.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 275

Перекрестные ссылки nitro::exception::code(), nitro::FA_FILE_READ, FileData, Mode и nitro::exception::what().

Используется в nitro::CSVFile::AppendRecord(), nitro::UnTARAbstraction::ExtractFile(), nitro::File::LoadBinDataFromFile(), nitro::UnTARAbstraction::ReadHeader() и nitro::CSVFile::ReadRecord().

        {
                try
                {
                        if( FileData == NULL )
                        {
                                throw( nitro::exception( std::string( "File was not opened" ) , 1 ) );
                        }
                        if( ( Mode & FA_FILE_READ ) == 0 )
                        {
                                throw( nitro::exception( "File was not opened for reading" , 1 ) );
                        }
                        
                #if     defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        DWORD           ReadBytes( 0 );

                        if( !ReadFile( * ( ( HANDLE * )FileData ) , ( LPVOID )Buffer , ( LONG )BufferLength , & ReadBytes , NULL ) )
                        {
                                throw( nitro::exception( "FileAbstraction::Read( char * Buffer , const std::size_t BufferLength )::An error occured while reading data from file" , 1 ) );
                        }

                        return( ( std::size_t )ReadBytes );
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        return( fread( Buffer , 1 , BufferLength , ( FILE * )FileData ) );
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Read( char * Buffer , const std::size_t BufferLength )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Read( char * Buffer , const std::size_t BufferLength )::An error occured" ) , 0 ) );
                }

                return( 0 );
        }

Граф вызовов:

void nitro::FileAbstraction::RenameFile ( const std::string &  FilePathFrom,
const std::string &  FilePathTo 
) [static]

Функция копирования файла.

Аргументы:
FilePathFrom - Путь переименовываемого файла.
FilePathTo - Новый путь к файлу.
Исключения:
nitro::exception Кидает исключение этого типа с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 441

Перекрестные ссылки nitro::exception::code(), RenameFile() и nitro::exception::what().

        {
                try
                {
                        RenameFile( FilePathFrom.c_str() , FilePathTo.c_str() );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::RenameFile( const std::string & FilePathFrom , const std::string & FilePathTo )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::RenameFile( const std::string & FilePathFrom , const std::string & FilePathTo )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

void nitro::FileAbstraction::RenameFile ( const char *  FilePathFrom,
const char *  FilePathTo 
) [static]

Функция копирования файла.

Аргументы:
FilePathFrom - Путь переименовываемого файла.
FilePathTo - Новый путь к файлу.
Исключения:
nitro::exception Кидает исключение этого типа с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 382

Перекрестные ссылки nitro::exception::code() и nitro::exception::what().

Используется в RenameFile().

        {
                try
                {
                #if     defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        if( MoveFile( FilePathFrom , FilePathTo ) == 0 )
                        {
                                throw( nitro::exception( std::string( "An error cccured while renaming file " ) + FilePathFrom , 0 ) );
                        }
                #endif
                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        if( rename( FilePathFrom , FilePathTo ) != 0 )
                        {
                                throw( nitro::exception( std::string( "An error cccured while renaming file " ) + FilePathFrom , 0 ) );
                        }
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::RenameFile( const char * FilePathFrom , const char * FilePathTo )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::RenameFile( const char * FilePathFrom , const char * FilePathTo )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

void nitro::FileAbstraction::Seek ( std::size_t  Offset,
std::size_t  theMode 
)

Установка курсора чтения/записи в файле.

Аргументы:
Offset - Смещение курсора.
theMode - Режим установки курсора.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 161

Перекрестные ссылки nitro::exception::code(), nitro::FA_FILE_BEGIN, nitro::FA_FILE_CURRENT, nitro::FA_FILE_END, FileData и nitro::exception::what().

Используется в nitro::CSVFile::AppendRecord(), nitro::File::FileSize(), nitro::UnTARAbstraction::GetCountOfFiles(), nitro::UnTARAbstraction::GotoFirstFile(), Open(), nitro::CSVFile::ReadRecord() и nitro::UnTARAbstraction::SetReadCursor().

        {
                try
                {
                        if( FileData == NULL )
                        {
                                throw( nitro::exception( std::string( "File was not opened" ) , 1 ) );
                        }

                #if     defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        switch( theMode )
                        {
                                case( FA_FILE_BEGIN ):
                                        SetFilePointer( * ( ( HANDLE * )FileData ) , ( LONG )Offset , NULL , FILE_BEGIN );
                                break;

                                case( FA_FILE_CURRENT ):
                                        SetFilePointer( * ( ( HANDLE * )FileData ) , ( LONG )Offset , NULL , FILE_CURRENT );
                                break;

                                case( FA_FILE_END ):
                                        SetFilePointer( * ( ( HANDLE * )FileData ) , ( LONG )Offset , NULL , FILE_END );
                                break;
                        }
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        switch( theMode )
                        {
                                case( FA_FILE_BEGIN ):
                                        fseek( ( FILE * )FileData , Offset , SEEK_SET );
                                break;

                                case( FA_FILE_CURRENT ):
                                        fseek( ( FILE * )FileData , Offset , SEEK_CUR );
                                break;

                                case( FA_FILE_END ):
                                        fseek( ( FILE * )FileData , Offset , SEEK_END );
                                break;
                        }
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Seek( std::size_t Offset , std::size_t theMode )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Seek( std::size_t Offset , std::size_t theMode )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:

std::size_t nitro::FileAbstraction::Tell ( void   ) 

Функция определения курсора в файле.

Возвращает:
Положение курсора в файле от начала файла.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 214

Перекрестные ссылки nitro::exception::code(), FileData и nitro::exception::what().

Используется в nitro::CSVFile::AppendRecord(), nitro::File::FileSize(), nitro::UnTARAbstraction::GetCountOfFiles() и nitro::CSVFile::ReadRecord().

        {
                try
                {
                        if( FileData == NULL )
                        {
                                throw( nitro::exception( std::string( "File was not opened" ) , 1 ) );
                        }
                #if     defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        return( ( std::size_t )SetFilePointer( * ( ( HANDLE * )FileData ) , ( LONG )NULL , NULL , FILE_CURRENT ) );
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        return( ( std::size_t )ftell( ( FILE * )FileData ) );
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Tell( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Tell( void )::An error occured" ) , 0 ) );
                }

                return( 0 );
        }

Граф вызовов:

void nitro::FileAbstraction::Write ( const char *  Buffer,
std::size_t  BufferLength 
)

Функция записи бинарных данных в файл.

Аргументы:
Buffer - Буффер данных.
BufferLength - Длина буффера данных.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

См. определение в файле file_abstraction.cpp строка 242

Перекрестные ссылки nitro::exception::code(), nitro::FA_FILE_WRITE, FileData, Mode и nitro::exception::what().

Используется в nitro::CSVFile::AppendRecord(), nitro::LogStream::operator<<(), nitro::File::SaveBinDataToFile(), nitro::XMLFile::SaveXML() и nitro::XMLTag::SaveXML().

        {
                try
                {
                        if( FileData == NULL )
                        {
                                throw( nitro::exception( std::string( "File was not opened" ) , 1 ) );
                        }
                        if( ( Mode & FA_FILE_WRITE ) == 0 )
                        {
                                throw( nitro::exception( "File was not opened for writing" , 1 ) );
                        }
                        
                #if     defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        DWORD           WriteBytes;

                        WriteFile( * ( ( HANDLE * )FileData ) , Buffer , ( LONG )BufferLength , & WriteBytes , NULL );
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        fwrite( Buffer , BufferLength , 1 , ( FILE * )FileData );
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Write( const char * Buffer , const std::size_t BufferLength )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "FileAbstraction::Write( const char * Buffer , const std::size_t BufferLength )::An error occured" ) , 0 ) );
                }
        }

Граф вызовов:


Данные класса

Данные необходимые для работы с файлом.

Автор:
Додонов А.А.

См. определение в файле file_abstraction.h строка 529

Используется в Close(), FileAbstraction(), Open(), Read(), Seek(), Tell() и Write().

std::size_t nitro::FileAbstraction::Mode [private]

Режим с которыйм открыли файл.

Автор:
Додонов А.А.

См. определение в файле file_abstraction.h строка 517

Используется в Open(), Read() и Write().


Объявления и описания членов классов находятся в файлах:

Generated by  doxygen 1.6.1