+Add utility to grab the folder of a file path

pull/289/head
diiigle 2013-12-31 19:26:11 +01:00
parent f5ef8772d8
commit 5cda765c0d
2 changed files with 24 additions and 0 deletions

View File

@ -223,6 +223,19 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
return ret;
}
// ------------------------------------------------------------------------------------------------
// Get folder of the file from path
/*static*/ std::string BaseImporter::GetFolderPath(const std::string& pFile, const char& osSeparator)
{
std::string::size_type pos = pFile.find_last_of(osSeparator);
// no path at all
if (pos == std::string::npos)
return "";
else
return pFile.substr(0, pos + 1);
}
// ------------------------------------------------------------------------------------------------
// Check for magic bytes at the beginning of the file.
/* static */ bool BaseImporter::CheckMagicToken(IOSystem* pIOHandler, const std::string& pFile,

View File

@ -300,6 +300,17 @@ public: // static utilities
static std::string GetExtension (
const std::string& pFile);
// -------------------------------------------------------------------
/** @brief Extract folder of the file from a string
* @param pFile Input file
* @param osSeparator Directory Separator of the current OS
* @return path to the files folder
* @note catch the osSeparator from a IOSystem
*/
static std::string GetFolderPath(
const std::string& pFile,
const char& osSeparator);
// -------------------------------------------------------------------
/** @brief Check whether a file starts with one or more magic tokens
* @param pFile Input file