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

Класс nitro::ZIPAbstraction

Класс для работы с zip архивами. Подробнее...

#include <system/zip_abstraction.h>

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

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

 ZIPAbstraction (void)
 ZIPAbstraction (const std::string &FilePath)
void Open (const std::string &FilePath)
void AddFile (const std::string &FilePath, const nitro::BinaryData &LoadedFile, const std::string &RelFolderPath="")
void AddFile (const std::string &FilePath, const std::string &RelFolderPath="")
void Close (void)
virtual ~ZIPAbstraction ()

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

 ZIPAbstraction (const ZIPAbstraction &)
ZIPAbstraction operator= (const ZIPAbstraction &)

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

void * File

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

Класс для работы с zip архивами.

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

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


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

nitro::ZIPAbstraction::ZIPAbstraction ( void   ) 

Конструктор.

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

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

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

                                             : File( 0 )
        {
                try
                {
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::CloseZIP( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::CloseZIP( void )::An error occured while unzipping file" ) , 1 ) );
                }
        }

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

nitro::ZIPAbstraction::ZIPAbstraction ( const std::string &  FilePath  ) 

Конструктор.

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

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

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

                                                                   : File( 0 )
        {
                try
                {
                        Close();

                        Open( FilePath );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::ZIPAbstraction( const std::string & FilePath /* = NULL */ )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::ZIPAbstraction( const std::string & FilePath /* = NULL */ )::An error occured while unzipping file" ) , 1 ) );
                }
        }

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

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

Деструктор.

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

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

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

        {
                try
                {
                        Close();
                }
                catch( nitro::exception e )
                {
                }
                catch( ... )
                {
                }
        }

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

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

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

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

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

{}


Методы

void nitro::ZIPAbstraction::AddFile ( const std::string &  FilePath,
const nitro::BinaryData LoadedFile,
const std::string &  RelFolderPath = "" 
)

Добавление файла в ZIP.

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

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

Перекрестные ссылки nitro::FSPath::AddEndSlash(), nitro::exception::code(), nitro::FSPath::ExtractFileName(), nitro::BinaryData::GetBuffer(), nitro::BinaryData::GetBufferLength(), nitro::File::GetLastModified() и nitro::exception::what().

Используется в AddFile() и nitro::ZIPUtilities::ArchiveDirectory().

        {
                try
                {
                        // сохраняем аттрибуты и время
                        zip_fileinfo            zfi;

                        zfi.internal_fa = 0;
                        zfi.external_fa = 0;
                        
                        tm                                      LastModifiedDate = nitro::File::GetLastModified( FilePath );

                        zfi.dosDate = 0;
                        zfi.tmz_date.tm_year = LastModifiedDate.tm_year + 1900;
                        zfi.tmz_date.tm_mon = LastModifiedDate.tm_mon;
                        zfi.tmz_date.tm_mday = LastModifiedDate.tm_mday;
                        zfi.tmz_date.tm_hour = LastModifiedDate.tm_hour;
                        zfi.tmz_date.tm_min = LastModifiedDate.tm_min;
                        zfi.tmz_date.tm_sec = LastModifiedDate.tm_sec;

                        // загружаем зипуемый файл
                        std::string                             FileName;
                        if( RelFolderPath == "" )
                        {
                                FileName = nitro::FSPath::ExtractFileName( std::string( FilePath ) );
                        }
                        else
                        {
                                FileName = nitro::FSPath::AddEndSlash( std::string( RelFolderPath ) ) + nitro::FSPath::ExtractFileName( std::string( FilePath ) );
                        }

                        // открываем архив
                        if( zipOpenNewFileInZip(        File , FileName.c_str() , & zfi , 
                                                                                NULL , 0 , NULL , 0 , 
                                                                                NULL , Z_DEFLATED , Z_DEFAULT_COMPRESSION ) != ZIP_OK )
                        {
                                throw( nitro::exception( std::string( "An error occured while opening zip file " ) + FileName , 1 ) );
                        }

                        if( zipWriteInFileInZip( File , LoadedFile.GetBuffer() , ( unsigned int )LoadedFile.GetBufferLength() ) != ZIP_OK )
                        {
                                throw( nitro::exception( std::string( "An error occured while saving data " ) + FilePath + " to zip file" , 1 ) );
                        }

                        zipCloseFileInZip( File );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::AddFile( const std::string & FilePath , const nitro::BinaryData & LoadedFile , const std::string & RelFolderPath /* = "" */ )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::AddFile( const std::string & FilePath , const nitro::BinaryData & LoadedFile , const std::string & RelFolderPath /* = "" */ )::An error occured while unzipping file" ) , 1 ) );
                }
        }

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

void nitro::ZIPAbstraction::AddFile ( const std::string &  FilePath,
const std::string &  RelFolderPath = "" 
)

Добавление файла в ZIP.

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

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

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

        {
                try
                {
                        nitro::BinaryData                       LoadedFile;

                        nitro::File::LoadBinDataFromFile( LoadedFile , FilePath );

                        AddFile( FilePath , LoadedFile , RelFolderPath );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::AddFile( const std::string & FilePath , const std::string & RelFolderPath /* = NULL */ )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::AddFile( const std::string & FilePath , const std::string & RelFolderPath /* = NULL */ )::An error occured while unzipping file" ) , 1 ) );
                }
        }

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

void nitro::ZIPAbstraction::Close ( void   ) 

Закрытие ZIP-файла.

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

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

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

Используется в nitro::ZIPUtilities::ArchiveDirectory(), Open(), ZIPAbstraction() и ~ZIPAbstraction().

        {
                try
                {
                        if( File ? zipClose( File , NULL ) : ZIP_OK != ZIP_OK )
                        {
                                throw( nitro::exception( std::string( "An error occured while closing zip file" ) , 1 ) );
                        }

                        File = NULL;
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::Close( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::Close( void )::An error occured while unzipping file" ) , 1 ) );
                }
        }

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

void nitro::ZIPAbstraction::Open ( const std::string &  FilePath  ) 

Открытие ZIP-файла.

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

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

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

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

        {
                try
                {
                        Close();

                        if( FilePath == "" || FilePath.size() == 0 )
                        {
                                throw( nitro::exception( std::string( "Invalid file path" ) , 1 ) );
                        }

                        if( nitro::File::FileExists( FilePath ) == false )
                        {
                                if( ( File = zipOpen( FilePath.c_str() , 0 ) ) == NULL )
                                {
                                        throw( nitro::exception( std::string( "File " ) + FilePath + " was not opened" , 1 ) );
                                }
                        }
                        else
                        {
                                if( ( File = zipOpen( FilePath.c_str() , 1 ) ) == NULL )
                                {
                                        throw( nitro::exception( std::string( "File " ) + FilePath + " was not opened" , 1 ) );
                                }
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::Open( const std::string & FilePath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "ZIPAbstraction::Open( const std::string & FilePath )::An error occured while unzipping file" ) , 1 ) );
                }
        }

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

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

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

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

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

{return( *this );}


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

void* nitro::ZIPAbstraction::File [private]

Загруженный файл.

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

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


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

Generated by  doxygen 1.6.1