mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-12 12:14:48 +00:00
Changed: Implement CPath::isAbsolutePath
This commit is contained in:
parent
2b91af0b45
commit
12ebf19bb9
2 changed files with 25 additions and 0 deletions
|
@ -514,6 +514,12 @@ public:
|
||||||
*/
|
*/
|
||||||
static std::string makePathAbsolute (const std::string &relativePath, const std::string &directory );
|
static std::string makePathAbsolute (const std::string &relativePath, const std::string &directory );
|
||||||
|
|
||||||
|
/** Return if a path is absolute or not.
|
||||||
|
* \param path - The path
|
||||||
|
* returns true if path is absolute or false if relative.
|
||||||
|
*/
|
||||||
|
static bool isAbsolutePath (const std::string &path);
|
||||||
|
|
||||||
/** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning.
|
/** If File in this list is added more than one in an addSearchPath, it doesn't launch a warning.
|
||||||
*/
|
*/
|
||||||
static void addIgnoredDoubleFile(const std::string &ignoredFile);
|
static void addIgnoredDoubleFile(const std::string &ignoredFile);
|
||||||
|
|
|
@ -2597,6 +2597,25 @@ std::string CPath::makePathAbsolute( const std::string &relativePath, const std:
|
||||||
return npath;
|
return npath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CPath::isAbsolutePath(const std::string &path)
|
||||||
|
{
|
||||||
|
if (path.empty()) return false;
|
||||||
|
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
// Windows root of current disk. Eg.: "\" or
|
||||||
|
// Windows network address. Eg.: \\someshare\path
|
||||||
|
if (path[0] == '\\') return true;
|
||||||
|
|
||||||
|
// Normal Windows absolute path. Eg.: C:\something
|
||||||
|
if (path.length() > 2 && isalpha(path[0]) && (path[1] == ':' ) && ((path[2] == '\\') || (path[2] == '/' ))) return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Unix filesystem absolute path (works also under Windows)
|
||||||
|
if (path[0] == '/') return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool CFile::setRWAccess(const std::string &filename)
|
bool CFile::setRWAccess(const std::string &filename)
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
|
|
Loading…
Reference in a new issue