Класс для работы с директориями. Подробнее...
#include <system/directory_abstraction.h>
Открытые члены | |
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 | ) |
Функция поиска следующей файловой сущности.
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 | ) |
Функция проверки что же мы нашли.
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 | - Проверяемый путь. |
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 | - Проверяемый путь. |
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 | ) |
Функция проверки что же мы нашли.
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 | - Проверяемый путь. |
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 | ) |
Функция проверки что же мы нашли.
nitro::exception | Throws exception wich contains error description. |
См. определение в файле 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 | - Проверяемый путь. |
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 | - Присваиваемый объект. |
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 ) ); } }
std::string nitro::DirectoryAbstraction::DirectoryPath [private] |
Путь к директории, с которой работаем.
См. определение в файле directory_abstraction.h строка 434
Используется в FindFirst(), IsDirectory() и IsFile().
void* nitro::DirectoryAbstraction::FindData [private] |
Поле для хранения информации об открытой директории.
См. определение в файле directory_abstraction.h строка 398
Используется в DirectoryAbstraction(), FindFirst(), FindNext(), GetName(), IsFile() и Release().
void* nitro::DirectoryAbstraction::FindHandle [private] |
Поле для хранения информации об открытой директории.
См. определение в файле directory_abstraction.h строка 410
Используется в DirectoryAbstraction(), FindFirst(), FindNext() и Release().
std::string nitro::DirectoryAbstraction::PathBuffer [mutable, private] |
Временный буффер, в котороый будет сохраняться путь найденной файловой сущности.
См. определение в файле directory_abstraction.h строка 422
Используется в GetName().