mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 03:09:18 +02:00
Merge branch 'tmj-dev' into milek-dev
This commit is contained in:
@@ -328,6 +328,20 @@ bool FileExists( std::string const &Filename ) {
|
||||
return( true == file.is_open() );
|
||||
}
|
||||
|
||||
std::pair<std::string, std::string>
|
||||
FileExists( std::vector<std::string> const &Names, std::vector<std::string> const &Extensions ) {
|
||||
|
||||
for( auto const &name : Names ) {
|
||||
for( auto const &extension : Extensions ) {
|
||||
if( FileExists( name + extension ) ) {
|
||||
return { name, extension };
|
||||
}
|
||||
}
|
||||
}
|
||||
// nothing found
|
||||
return { {}, {} };
|
||||
}
|
||||
|
||||
// returns time of last modification for specified file
|
||||
std::time_t
|
||||
last_modified( std::string const &Filename ) {
|
||||
@@ -363,3 +377,13 @@ replace_slashes( std::string &Filename ) {
|
||||
std::begin( Filename ), std::end( Filename ),
|
||||
'\\', '/' );
|
||||
}
|
||||
|
||||
// returns potential path part from provided file name
|
||||
std::string
|
||||
substr_path( std::string const &Filename ) {
|
||||
|
||||
return (
|
||||
Filename.rfind( '/' ) != std::string::npos ?
|
||||
Filename.substr( 0, Filename.rfind( '/' ) + 1 ) :
|
||||
"" );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user