mirror of https://github.com/PCSX2/pcsx2.git
Added Path::GetFilenameWithoutExt, and fixed some other PathUtil API layouts.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@692 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
a09157ab59
commit
8614bbd0f8
|
@ -191,27 +191,40 @@ string ReplaceFilename( const string& src, const string& newfilename )
|
|||
|
||||
if( !newfilename.empty() )
|
||||
{
|
||||
dest += '.';
|
||||
dest += Separator;
|
||||
dest += newfilename;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
void GetFilename( const string& src, string& dest )
|
||||
string GetFilename( const string& src )
|
||||
{
|
||||
int pos = _findFilenamePosition( src );
|
||||
dest.assign( src.begin()+pos, src.end() );
|
||||
return string( src.begin()+pos, src.end() );
|
||||
}
|
||||
|
||||
void GetDirectory( const string& src, string& dest )
|
||||
string GetFilenameWithoutExt( const string& src )
|
||||
{
|
||||
string fname( GetFilename( src ) );
|
||||
|
||||
int pos = fname.find_last_of( '.' );
|
||||
if( pos == string::npos || pos == 0 )
|
||||
return fname;
|
||||
else
|
||||
return string( fname.begin(), fname.begin()+pos );
|
||||
}
|
||||
|
||||
string GetDirectory( const string& src )
|
||||
{
|
||||
int pos = _findFilenamePosition( src );
|
||||
if( pos == 0 )
|
||||
dest.clear();
|
||||
return string();
|
||||
else
|
||||
dest.assign( src.begin(), src.begin()+pos );
|
||||
return string( src.begin(), src.begin()+pos );
|
||||
}
|
||||
|
||||
// This function mimics the old ANSI C splitpath function. It's more or less superceeded
|
||||
// by one of the many other Path utility functions, but someone might find it useful.
|
||||
void Split( const string& src, string& destpath, string& destfile )
|
||||
{
|
||||
int pos = _findFilenamePosition( src );
|
||||
|
@ -230,13 +243,13 @@ void Split( const string& src, string& destpath, string& destfile )
|
|||
|
||||
// Assigns the base/root directory of the given path into dest.
|
||||
// Example /this/that/something.txt -> dest == "/"
|
||||
void GetRootDirectory( const string& src, string& dest )
|
||||
string GetRootDirectory( const string& src )
|
||||
{
|
||||
int pos = src.find_first_of( Delimiters );
|
||||
if( pos == string::npos )
|
||||
dest.clear();
|
||||
return string();
|
||||
else
|
||||
dest.assign( src.begin(), src.begin()+pos );
|
||||
return string( src.begin(), src.begin()+pos );
|
||||
}
|
||||
|
||||
void CreateDirectory( const string& src )
|
||||
|
|
|
@ -34,9 +34,10 @@ namespace Path
|
|||
extern std::string Combine( const std::string& srcPath, const std::string& srcFile );
|
||||
extern std::string ReplaceExtension( const std::string& src, const std::string& ext );
|
||||
extern std::string ReplaceFilename( const std::string& src, const std::string& newfilename );
|
||||
extern void GetFilename( const std::string& src, std::string& dest );
|
||||
extern void GetDirectory( const std::string& src, std::string& dest );
|
||||
extern void GetRootDirectory( const std::string& src, std::string& dest );
|
||||
extern std::string GetFilename( const std::string& src );
|
||||
extern std::string GetDirectory( const std::string& src );
|
||||
extern std::string GetFilenameWithoutExt( const string& src );
|
||||
extern std::string GetRootDirectory( const std::string& src );
|
||||
extern void Split( const std::string& src, std::string& destpath, std::string& destfile );
|
||||
|
||||
extern void CreateDirectory( const std::string& src );
|
||||
|
|
Loading…
Reference in New Issue