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

Класс nitro::FSPath

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

#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 ) );
                }
        }

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

template<class str_type >
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 ) );
                }
        }

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

template<class str_type >
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 ) );
                }
        }

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

template<class cont >
void nitro::FSPath::ExplodePath ( const std::string &  Path,
cont &  PathSegments 
) [static]

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

Аргументы:
Path - Путь.
PathSegments - Сегменты пути после разбивки.
Заметки:
Контейнер типа cont должен поддерживать операцию вставки в конец и иметь двунаправленные итераторы.
Исключения:
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 ) );
                }
        }

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

template<class str_type >
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 ) );
                }
        }

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

template<class str_type >
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 ) );
                }
        }

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

template<class str_type >
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 ) );
                }
        }

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

template<class str_type >
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 ) );
                }
        }

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


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

Generated by  doxygen 1.6.1