--- linuxsampler/trunk/src/common/Path.cpp 2014/03/03 12:02:40 2528 +++ linuxsampler/trunk/src/common/Path.cpp 2014/03/04 20:41:47 2529 @@ -1,6 +1,6 @@ /*************************************************************************** * * - * Copyright (C) 2007 Christian Schoenebeck * + * Copyright (C) 2007-2014 Christian Schoenebeck * * * * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -27,7 +27,15 @@ namespace LinuxSampler { -Path::Path() : drive(0) { +Path::Path() : drive(0), absolute(false) { +} + +Path::Path(std::string path) { + #if WIN32 + *this = fromWindows(path); + #else + *this = fromPosix(path); + #endif } void Path::appendNode(std::string Name) { @@ -37,6 +45,7 @@ void Path::setDrive(const char& Drive) { drive = Drive; + absolute = true; } std::string Path::toPosix() const { @@ -188,6 +197,9 @@ s.replace(pos, 3, pcAscii); } } + // check whether given string reflects an absolute path + // (indicated by a forward slash as first character on POSIX) + result.absolute = !path.empty() && path[0] == '/'; return result; } @@ -241,6 +253,10 @@ } } + // check whether given string reflects an absolute path + // (indicated either by a backslash or drive at the beginning on Windows) + result.absolute = result.drive || (!path.empty() && path[0] == '\\'); + return result; } @@ -298,4 +314,8 @@ return p.stripLastName(); } +bool Path::isAbsolute() const { + return absolute; +} + } // namespace LinuxSampler