Commit b65c0560 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Adding file system functions to get base path and absolute path of a file or folder

parent f1064022
......@@ -42,6 +42,15 @@ ITA_BASE_API bool doesFileExist(const std::string& sPath);
//! Prfen ob ein Pfad existiert und auf ein Verzeichnis zeigt
ITA_BASE_API bool doesDirectoryExist(const std::string& sPath);
namespace ITA
{
namespace FileSystemUtils
{
ITA_BASE_API std::string GetAbsolutePath( const std::string& sFilePath_RelativeToExecutionFolder );
ITA_BASE_API std::string GetBasePath( const std::string& sFilePath );
}
}
//! Prfen ob ein Pfad auf eine Datei zeigt
ITA_BASE_API bool isFile(const std::string& sPath);
......
......@@ -189,3 +189,34 @@ bool listFilesInDirectory( const std::string& sPath, std::vector<std::string>& v
return true;
}
namespace ITA
{
namespace FileSystemUtils
{
std::string GetAbsolutePath( const std::string& sFilePath_RelativeToExecutionFolder )
{
// Inspiration by FOX
#if !defined(WIN32) && !defined(PLATFORM_X64)
ITA_EXCEPT_NOT_IMPLEMENTED;
#else
char cAbsoluteFilePath[ MAX_PATH ];
GetFullPathNameA( sFilePath_RelativeToExecutionFolder.c_str(), MAX_PATH, cAbsoluteFilePath, nullptr );
return std::string( cAbsoluteFilePath );
#endif
}
std::string GetBasePath( const std::string& sFilePath )
{
// Inspiration by FOX
#if !defined(WIN32) && !defined(PLATFORM_X64)
ITA_EXCEPT_NOT_IMPLEMENTED;
#else
char cDrive[ MAX_PATH ];
char cDir[ MAX_PATH ];
_splitpath( sFilePath.c_str(), cDrive, cDir, nullptr, nullptr );
return std::string( cDrive ) + std::string( cDir );
#endif
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment