Класс для работы с путями. Подробнее...
#include <utilities/string_utilities.h>
Открытые статические члены | |
static void | AddEndSlash (const char *OldPath, char *NewPath) |
template<class str_type > | |
static str_type | AddEndSlash (const str_type &Path) |
static void | DeleteEndSlash (const char *OldPath, char *NewPath) |
template<class str_type > | |
static str_type | DeleteEndSlash (const str_type &OldPath) |
static char * | ExtractFilePath (const char *FilePath, char *ClearedFilePath) |
template<class str_type > | |
static str_type | ExtractFilePath (const str_type &FilePath) |
static char * | ExtractFileName (const char *FilePath, char *FileName) |
template<class str_type > | |
static str_type | ExtractFileName (const str_type &FilePath) |
static void | ExtractModuleName (const char *file_name, char *module_name) |
template<class str_type > | |
static str_type | ExtractModuleName (const str_type &FileName) |
static char * | ExtractFileExtension (const char *FileName, char *file_extension) |
template<class str_type > | |
static str_type | ExtractFileExtension (const str_type &FileName) |
template<class cont > | |
static void | ExplodePath (const std::string &Path, cont &PathSegments) |
Класс для работы с путями.
См. определение в файле string_utilities.h строка 52
void nitro::FSPath::AddEndSlash | ( | const char * | OldPath, | |
char * | NewPath | |||
) | [static] |
Функция добавления слэша к пути, если слэш уже был то новый слэш добавлен не будет.
OldPath | - Старый путь. | |
NewPath | - Новый путь. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.cpp строка 13
Перекрестные ссылки nitro::exception::code() и nitro::exception::what().
Используется в AddEndSlash(), nitro::ZIPAbstraction::AddFile(), nitro::Directory::DirectoryExists(), nitro::UnTARAbstraction::ExtractFile(), nitro::DirectoryAbstraction::FindFirst(), nitro::UnZIPAbstraction::UnZIPFile() и nitro::WalkThroughDirectory().
{ try { strcpy( NewPath , OldPath ); if( NewPath[ strlen( NewPath ) - 1 ] != '/' && NewPath[ strlen( NewPath ) - 1 ] != '\\' ) { strcat( NewPath , "/" ); } } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::AddEndSlash( const char * OldPath , char * NewPath )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::AddEndSlash( const char * OldPath , char * NewPath )::An error occured" ) , 1 ) ); } }
str_type nitro::FSPath::AddEndSlash | ( | const str_type & | Path | ) | [static] |
Функция добавления слэша к пути, если слэш уже был то новый слэш добавлен не будет.
Path | - Старый путь. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.h строка 372
Перекрестные ссылки AddEndSlash(), nitro::exception::code() и nitro::exception::what().
{ try { if( Path[ Path.length() - 1 ] == '/' || Path[ Path.length() - 1 ] == '\\' ) { return( Path ); } else { char * TmpStr( new char[ Path.length() + 2 ] ); memset( TmpStr , 0 , Path.length() + 2 ); AddEndSlash( Path.c_str() , TmpStr ); std::string RetStr( TmpStr ); delete [] TmpStr; return( RetStr ); } } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::AddEndSlash( const str_type & Path )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::AddEndSlash( const str_type & Path )::An error occured" ) , 0 ) ); } }
str_type nitro::FSPath::DeleteEndSlash | ( | const str_type & | OldPath | ) | [static] |
Функция удаления слэша из пути, если слэша нет, то соответственно ничего удалять не надо.
OldPath | - Старый путь. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.h строка 403
Перекрестные ссылки nitro::exception::code(), DeleteEndSlash() и nitro::exception::what().
{ try { char * CharChain( new char[ OldPath.length() + 2 ] ); memset( CharChain , 0 , OldPath.length() + 2 ); DeleteEndSlash( OldPath.c_str() , CharChain ); str_type RetString( CharChain ); delete [] CharChain; return( RetString ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::DeleteEndSlash( const str_type & OldPath )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::DeleteEndSlash( const str_type & OldPath )::An error occured" ) , 0 ) ); } }
void nitro::FSPath::DeleteEndSlash | ( | const char * | OldPath, | |
char * | NewPath | |||
) | [static] |
Функция удаления слэша из пути, если слэша нет, то соответственно ничего удалять не надо.
OldPath | - Старый путь. | |
NewPath | - Новый путь. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.cpp строка 34
Перекрестные ссылки nitro::exception::code() и nitro::exception::what().
Используется в DeleteEndSlash() и nitro::Directory::ForceCreateDirectory().
{ try { if( OldPath[ strlen( OldPath ) - 1 ] == '/' || OldPath[ strlen( OldPath ) - 1 ] == '\\' ) { memset( NewPath , 0 , strlen( OldPath ) ); strncpy( NewPath , OldPath , strlen( OldPath ) - 1 ); } else { strcpy( NewPath , OldPath ); } } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::DeleteEndSlash( const char * OldPath , char * NewPath )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::DeleteEndSlash( const char * OldPath , char * NewPath )::An error occured" ) , 1 ) ); } }
void nitro::FSPath::ExplodePath | ( | const std::string & | Path, | |
cont & | PathSegments | |||
) | [static] |
Функция для разбивки пути к файлу на состовляющие.
Path | - Путь. | |
PathSegments | - Сегменты пути после разбивки. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.h строка 526
Перекрестные ссылки nitro::exception::code(), ExtractFileName(), ExtractFilePath() и nitro::exception::what().
{ try { char * PathPart( new char [ Path.size() + 1 ] ); char * PathSegment( new char [ Path.size() + 1 ] ); std::string TmpPath( Path ); do { nitro::FSPath::ExtractFileName( TmpPath.c_str() , PathSegment ); PathSegments.push_back( std::string( PathSegment ) ); nitro::FSPath::ExtractFilePath( TmpPath.c_str() , PathPart ); TmpPath = PathPart; } while( strlen( PathPart ) ); delete [] PathPart; delete [] PathSegment; std::reverse( PathSegments.begin() , PathSegments.end() ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::ExplodePath( const std::string & Path , cont & PathSegments )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::ExplodePath( const std::string & Path , cont & PathSegments )::An error occured" ) , 0 ) ); } }
str_type nitro::FSPath::ExtractFileExtension | ( | const str_type & | FileName | ) | [static] |
Функция возвращает расширение файла.
FileName | - Имя файла чьё расширение нам нужно. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.h строка 501
Перекрестные ссылки nitro::exception::code(), ExtractFileExtension() и nitro::exception::what().
{ try { char * CharChain( new char[ FileName.length() + 1 ] ); memset( CharChain , 0 , CharChain ); ExtractFileExtension( FileName.c_str() , FileName.length() + 1 ); str_type RetString( CharChain ); delete [] CharChain; return( RetString ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::ExtractFileExtension( const str_type & file_name )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::ExtractFileExtension( const str_type & file_name )::An error occured" ) , 0 ) ); } }
char * nitro::FSPath::ExtractFileExtension | ( | const char * | FileName, | |
char * | file_extension | |||
) | [static] |
Функция возвращает расширение файла.
FileName | - Имя файла чьё расширение нам нужно. | |
file_extension | - Строка, куда будет записано расширение. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.cpp строка 155
Перекрестные ссылки nitro::exception::code() и nitro::exception::what().
Используется в ExtractFileExtension().
{ try { int i( ( int )strlen( file_name ) - 1 ); file_extension[ 0 ] = '\0'; for( ; i >= 0 ; i-- ) { if( file_name[ i ] == '.' ) { goto end_loop; } } end_loop:; strncpy( file_extension , &file_name[ i + 1 ] , strlen( file_name ) - i ); return( file_extension ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::ExtractFileExtension( const char * file_name , char * file_extension )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::ExtractFileExtension( const char * file_name , char * file_extension )::An error occured" ) , 1 ) ); } }
str_type nitro::FSPath::ExtractFileName | ( | const str_type & | FilePath | ) | [static] |
Враппер для функции ExtractFileName( const char * FilePath , char * FileName ).
FilePath | - Путь к файлу. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.h строка 451
Перекрестные ссылки nitro::exception::code(), ExtractFileName() и nitro::exception::what().
{ try { char * CharChain( new char[ FilePath.length() + 1 ] ); memset( CharChain , 0 , FilePath.length() + 1 ); ExtractFileName( FilePath.c_str() , CharChain ); str_type RetString( CharChain ); delete [] CharChain; return( RetString ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::ExtractFileName( const str_type & FilePath )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::ExtractFileName( const str_type & FilePath )::An error occured" ) , 0 ) ); } }
char * nitro::FSPath::ExtractFileName | ( | const char * | FilePath, | |
char * | FileName | |||
) | [static] |
Функция из пути к файлу выделяет имя файла. Если выделить имя файла не удалось, то в FileName записывается FilePath.
FilePath | - Путь к файлу. | |
FileName | - Имя файла. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.cpp строка 93
Перекрестные ссылки nitro::exception::code() и nitro::exception::what().
Используется в nitro::ZIPAbstraction::AddFile(), nitro::ProcessAbstraction::CreateProcess(), ExplodePath(), nitro::UnTARAbstraction::ExtractFile(), ExtractFileName() и nitro::UnZIPAbstraction::UnZIPFile().
{ try { int i( ( int )strlen( FilePath ) - 1 ); FileName[ 0 ] = '\0'; for( ; i >= 0 ; i-- ) { if( FilePath[ i ] == '/' || FilePath[ i ] == '\\' ) { goto end_loop; } } // типа не удалось выделить имя файла strcpy( FileName , FilePath ); return( FileName ); end_loop:; // выделяем имя файла strncpy( FileName , & FilePath[ i + 1 ] , strlen( FilePath ) - i ); return( FileName ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::ExtractFileName( const char * FilePath , char * FileName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::ExtractFileName( const char * FilePath , char * FileName )::An error occured" ) , 1 ) ); } }
str_type nitro::FSPath::ExtractFilePath | ( | const str_type & | FilePath | ) | [static] |
Функция из полного пути к файлу выделяет только путь (без имени файла).
FilePath | - Путь к файлу (включая имя файла). |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.h строка 427
Перекрестные ссылки nitro::exception::code(), ExtractFilePath() и nitro::exception::what().
{ try { char * CharChain( new char[ FilePath.length() + 2 ] ); memset( CharChain , 0 , FilePath.length() + 2 ); str_type RetString( ExtractFilePath( FilePath.c_str() , CharChain ) ); delete [] CharChain; return( RetString ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::ExtractFilePath( const str_type & FilePath )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::ExtractFilePath( const str_type & FilePath )::An error occured" ) , 0 ) ); } }
char * nitro::FSPath::ExtractFilePath | ( | const char * | FilePath, | |
char * | ClearedFilePath | |||
) | [static] |
Функция из полного пути к файлу выделяет только путь (без имени файла).
FilePath | - Путь к файлу (включая имя файла). | |
ClearedFilePath | - Путь к файлу (без имени файла, концевой слэш отсутствует) |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.cpp строка 58
Перекрестные ссылки nitro::exception::code() и nitro::exception::what().
Используется в ExplodePath(), ExtractFilePath(), nitro::Directory::ForceCreateDirectory() и nitro::File::ForceCreateFile().
{ try { int i( ( int )strlen( FilePath ) - 1 ); ClearedFilePath[ 0 ] = '\0'; for( ; i >= 0 ; i-- ) { if( FilePath[ i ] == '/' || FilePath[ i ] == '\\' ) { goto end_loop; } } end_loop:; if( i >= 0 ) { strncpy( ClearedFilePath , FilePath , i ); ClearedFilePath[ i ] = '\0'; } else { ClearedFilePath[ 0 ] = '\0'; } return( ClearedFilePath ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::ExtractFilePath( const char * FilePath , char * ClearedFilePath )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::ExtractFilePath( const char * FilePath , char * ClearedFilePath )::An error occured" ) , 1 ) ); } }
str_type nitro::FSPath::ExtractModuleName | ( | const str_type & | FileName | ) | [static] |
Функция из пары [имя модуля].[расширение] выделяет [имя модуля].
FileName | - Имя файла. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.h строка 476
Перекрестные ссылки nitro::exception::code(), ExtractModuleName() и nitro::exception::what().
{ try { char * CharChain( new char[ FileName.length() + 1 ] ); memset( CharChain , 0 , FileName.length() + 1 ); ExtractModuleName( FileName.c_str() , CharChain ); str_type RetString( CharChain ); delete [] CharChain; return( RetString ); } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::ExtractModuleName( const str_type & FileName )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::ExtractModuleName( const str_type & FileName )::An error occured" ) , 0 ) ); } }
void nitro::FSPath::ExtractModuleName | ( | const char * | file_name, | |
char * | module_name | |||
) | [static] |
Функция из пары [имя модуля].[расширение] выделяет [имя модуля].
file_name | - Имя файла. | |
module_name | - Имя модуля. |
nitro::exception | Кидает исключение с описанием ошибки. |
См. определение в файле string_utilities.cpp строка 128
Перекрестные ссылки nitro::exception::code() и nitro::exception::what().
Используется в ExtractModuleName().
{ try { int i( ( int )strlen( file_name ) - 1 ); module_name[ 0 ] = '\0'; for( ; i >= 0 ; i-- ) { if( file_name[ i ] == '.' ) { goto end_loop; } } end_loop:; strncpy( module_name , file_name , i ); module_name[ i ] = '\0'; } catch( nitro::exception e ) { throw( nitro::exception( std::string( "FSPath::ExtractModuleName( const char * file_name , char * module_name )::" ) + e.what() , e.code() ) ); } catch( ... ) { throw( nitro::exception( std::string( "FSPath::ExtractModuleName( const char * file_name , char * module_name )::An error occured" ) , 1 ) ); } }