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

Класс nitro::DirectoryAbstraction

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

#include <system/directory_abstraction.h>

Граф связей класса nitro::DirectoryAbstraction:
Collaboration graph
[см. легенду]

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

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

 DirectoryAbstraction (void)
bool FindFirst (const char *DirectoryPath)
bool FindFirst (const std::string &DirectoryPath)
bool FindNext (void)
bool IsDirectory (void)
bool IsFile (void)
bool IsDots (void)
const char * GetName (void)
void Release (void)
virtual ~DirectoryAbstraction ()

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

static bool IsDirectory (const char *DirectoryPath)
static bool IsDirectory (const std::string &DirectoryPath)
static bool IsFile (const char *FilePath)
static bool IsFile (const std::string &FilePath)
static void CreateDirectory (const char *DirPath)
static void CreateDirectory (const std::string &DirPath)

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

 DirectoryAbstraction (const DirectoryAbstraction &DirectoryAbstraction)
DirectoryAbstraction operator= (const DirectoryAbstraction &DirectoryAbstraction)

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

void * FindData
void * FindHandle
std::string PathBuffer
std::string DirectoryPath

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

Класс для работы с директориями.

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

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


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

nitro::DirectoryAbstraction::DirectoryAbstraction ( void   ) 

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

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

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

Перекрестные ссылки FindData и FindHandle.

        {
                FindHandle = NULL;

                FindData = NULL;
        }

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

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

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

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

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

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

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

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

Конструктор копирования.

Аргументы:
DirectoryAbstraction - объект, посредством которого будет конструироваться *this.
Исключения:
nitro::exception Кидает исключение с описанием ошибки.
Автор:
Додонов А.А.

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

{}


Методы

void nitro::DirectoryAbstraction::CreateDirectory ( const char *  DirPath  )  [static]

Функция создания директории.

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

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

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

Используется в CreateDirectory() и nitro::Directory::ForceCreateDirectory().

        {
                try
                {
                #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        if( !::CreateDirectoryA( DirPath , NULL ) )
                        {
                                throw( nitro::exception( std::string( "An error occured while creating directory" ) , 0 ) );
                        }
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        if( mkdir( DirPath , S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH ) == -1 )
                        {
                                throw( nitro::exception( std::string( "An error occured while creating directory" ) , 0 ) );
                        }
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::CreateDirectory( const char * DirPath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::CreateDirectory( const char * DirPath )::An error occured" ) , 0 ) );
                }
        }

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

void nitro::DirectoryAbstraction::CreateDirectory ( const std::string &  DirPath  )  [static]

Функция создания директории.

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

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

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

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

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

bool nitro::DirectoryAbstraction::FindFirst ( const std::string &  DirectoryPath  ) 

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

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

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

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

        {
                try
                {
                        return( FindFirst( DirectoryPath.c_str() ) );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::FindFirst( const std::string & DirectoryPath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::FindFirst( const std::string & DirectoryPath )::An error occured while setting folder path" ) , 0 ) );
                }
        }

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

bool nitro::DirectoryAbstraction::FindFirst ( const char *  DirectoryPath  ) 

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

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

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

Перекрестные ссылки nitro::FSPath::AddEndSlash(), nitro::exception::code(), DirectoryPath, FindData, FindHandle, IsDirectory(), Release() и nitro::exception::what().

Используется в nitro::Directory::DirectoryExists(), FindFirst() и nitro::WalkThroughDirectory().

        {
                try
                {
                        Release();
                        
                        if( IsDirectory( theDirectoryPath ) == false )
                        {
                                throw( nitro::exception( std::string( "Path " ) + theDirectoryPath + " must lead to directory" , 1 ) );
                        }
                        
                        DirectoryPath = theDirectoryPath;
                        
                #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                
                        FindData = ( void * ) new WIN32_FIND_DATA;

                        FindHandle = ( void * ) new HANDLE;

                        * ( ( HANDLE * )FindHandle ) = ::FindFirstFile( ( nitro::FSPath::AddEndSlash( std::string( theDirectoryPath ) ) + "*" ).c_str() , ( WIN32_FIND_DATA * )FindData );
                        
                        return( * ( ( HANDLE * )FindHandle ) == INVALID_HANDLE_VALUE );
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        FindHandle = ( void * )opendir( theDirectoryPath );
                        
                        return( FindHandle == NULL );
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::FindFirst( const char * theDirectoryPath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::FindFirst( const char * theDirectoryPath )::An error occured while setting folder path" ) , 0 ) );
                }
                return( true );
        }

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

bool nitro::DirectoryAbstraction::FindNext ( void   ) 

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

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

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

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

Используется в nitro::WalkThroughDirectory().

        {
                try
                {
                #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        return( ::FindNextFile( * ( HANDLE * )FindHandle , ( WIN32_FIND_DATA * )FindData ) == 0 );
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        return( ( FindData = readdir( ( DIR * )FindHandle ) ) == NULL );
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::FindNext( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::FindNext( void )::An error occured while finding next item" ) , 0 ) );
                }
                return( true );
        }

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

const char * nitro::DirectoryAbstraction::GetName ( void   ) 

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

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

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

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

Используется в IsDirectory(), IsDots(), IsFile() и nitro::WalkThroughDirectory().

        {
                try
                {
                #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        PathBuffer = ( ( WIN32_FIND_DATA * )FindData )->cFileName;
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        PathBuffer = ( ( dirent * )FindData )->d_name;
                #endif

                        return( PathBuffer.c_str() );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::GetName( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::GetName( void )::An error occured" ) , 0 ) );
                }
        }

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

bool nitro::DirectoryAbstraction::IsDirectory ( void   ) 

Функция проверки что же мы нашли.

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

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

Перекрестные ссылки nitro::exception::code(), DirectoryPath, GetName(), IsDots(), IsFile() и nitro::exception::what().

Используется в FindFirst(), IsDirectory() и nitro::WalkThroughDirectory().

        {
                try
                {
                #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        return( IsFile() == false && IsDots() == false );
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        DIR *                   d( opendir( ( DirectoryPath + GetName() ).c_str() ) );
                        
                        if( d )
                        {
                                closedir( d );
                                return( true );
                        }
                        else
                        {
                                return( false );
                        }
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsDirectory( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsDirectory( void )::An error occured while getting info (f)" ) , 0 ) );
                }
        }

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

bool nitro::DirectoryAbstraction::IsDirectory ( const char *  DirectoryPath  )  [static]

Функция проверки пути.

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

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

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

        {
                try
                {
                #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        return( ( GetFileAttributes( theDirectoryPath ) & FILE_ATTRIBUTE_DIRECTORY ) != 0 );
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        DIR *                   d( opendir( theDirectoryPath ) );
                        
                        if( d )
                        {
                                closedir( d );
                                return( true );
                        }
                        else
                        {
                                return( false );
                        }
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsDirectory( const char * theDirectoryPath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsDirectory( const char * theDirectoryPath )::An error occured while getting info (d)" ) , 0 ) );
                }
                return( true );
        }

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

bool nitro::DirectoryAbstraction::IsDirectory ( const std::string &  DirectoryPath  )  [static]

Функция проверки пути.

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

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

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

        {
                try
                {
                        return( IsDirectory( theDirectoryPath.c_str() ) );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsDirectory( const std::string & theDirectoryPath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsDirectory( const std::string & theDirectoryPath )::An error occured while getting info (d)" ) , 0 ) );
                }
        }

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

bool nitro::DirectoryAbstraction::IsDots ( void   ) 

Функция проверки что же мы нашли.

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

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

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

Используется в IsDirectory() и nitro::WalkThroughDirectory().

        {
                try
                {
                        return( std::string( GetName() ) == "." || std::string( GetName() ) == ".." );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsDots( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsDots( void )::An error occured while getting info (d)" ) , 0 ) );
                }
        }

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

bool nitro::DirectoryAbstraction::IsFile ( const std::string &  FilePath  )  [static]

Функция проверки пути.

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

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

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

        {
                try
                {
                        return( IsFile( FilePath.c_str() ) );
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsFile( const std::string & FilePath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsFile( const std::string & FilePath )::An error occured while getting info (d)" ) , 0 ) );
                }
                return( true );
        }

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

bool nitro::DirectoryAbstraction::IsFile ( void   ) 

Функция проверки что же мы нашли.

Возвращает:
true если найден файл, иначе false.
Исключения:
nitro::exception Throws exception wich contains error description.
Автор:
Dodonov A.A.

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

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

Используется в IsDirectory() и IsFile().

        {
                try
                {
                #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        return( ( ( ( WIN32_FIND_DATA * )FindData )->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) == 0 );
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        struct stat             s;
                        
                        return( stat( ( std::string( DirectoryPath ) + GetName() ).c_str() , & s ) == 0 );
                #endif

                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsFile( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsDots( void )::An error occured while getting info (d)" ) , 0 ) );
                }
                return( true );
        }

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

bool nitro::DirectoryAbstraction::IsFile ( const char *  FilePath  )  [static]

Функция проверки пути.

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

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

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

        {
                try
                {
                #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                        return( ( GetFileAttributes( FilePath ) & FILE_ATTRIBUTE_DIRECTORY ) == 0 );
                #endif

                #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                        struct stat             s;

                        return( stat( FilePath , & s ) == 0 );
                #endif
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsFile( const char * FilePath )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::IsFile( const char * FilePath )::An error occured while getting info (d)" ) , 0 ) );
                }
                return( true );
        }

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

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

Оператор присваивания.

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

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

{return( *this );}

void nitro::DirectoryAbstraction::Release ( void   ) 

Функция очистки выделенных ресурсов.

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

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

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

Используется в FindFirst() и ~DirectoryAbstraction().

        {
                try
                {
                        if( FindHandle )
                        {
                        #if defined( WIN32_PLATFORM ) || defined( MINGW_PLATFORM )
                                ::FindClose( * ( ( HANDLE * )FindHandle ) );

                                delete ( HANDLE * ) FindHandle;
                                delete ( WIN32_FIND_DATA * ) FindData;
                        #endif

                        #if     defined( NIX_PLATFORM ) || defined( CYGWIN_PLATFORM )
                                closedir( ( DIR * )FindHandle );
                        #endif

                                FindData = FindHandle = NULL;
                        }
                }
                catch( nitro::exception e )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::Release( void )::" ) + e.what() , e.code() ) );
                }
                catch( ... )
                {
                        throw( nitro::exception( std::string( "DirectoryAbstraction::Release( void )::An error occured" ) , 0 ) );
                }
        }

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


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

Путь к директории, с которой работаем.

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

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

Используется в FindFirst(), IsDirectory() и IsFile().

Поле для хранения информации об открытой директории.

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

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

Используется в DirectoryAbstraction(), FindFirst(), FindNext(), GetName(), IsFile() и Release().

Поле для хранения информации об открытой директории.

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

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

Используется в DirectoryAbstraction(), FindFirst(), FindNext() и Release().

std::string nitro::DirectoryAbstraction::PathBuffer [mutable, private]

Временный буффер, в котороый будет сохраняться путь найденной файловой сущности.

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

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

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


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

Generated by  doxygen 1.6.1