+Add utility to grab the folder of a file path
parent
f5ef8772d8
commit
5cda765c0d
|
@ -223,6 +223,19 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
|
||||||
return ret;
|
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.
|
// Check for magic bytes at the beginning of the file.
|
||||||
/* static */ bool BaseImporter::CheckMagicToken(IOSystem* pIOHandler, const std::string& pFile,
|
/* static */ bool BaseImporter::CheckMagicToken(IOSystem* pIOHandler, const std::string& pFile,
|
||||||
|
|
|
@ -300,6 +300,17 @@ public: // static utilities
|
||||||
static std::string GetExtension (
|
static std::string GetExtension (
|
||||||
const std::string& pFile);
|
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
|
/** @brief Check whether a file starts with one or more magic tokens
|
||||||
* @param pFile Input file
|
* @param pFile Input file
|
||||||
|
|
Loading…
Reference in New Issue