1 #ifndef SimTK_SimTKCOMMON_PATHNAME_H_
2 #define SimTK_SimTKCOMMON_PATHNAME_H_
133 static void deconstructPathname(
const std::string& pathname,
134 bool& dontApplySearchPath,
135 std::string& directory,
136 std::string& fileName,
137 std::string& extension);
164 static void deconstructPathnameUsingSpecifiedWorkingDirectory(
const std::string& swd,
165 const std::string& pathname,
166 std::string& directory,
167 std::string& fileName,
168 std::string& extension);
174 std::string& directory,
175 std::string& fileName,
176 std::string& extension) {
177 bool dontApplySearchPath;
178 deconstructPathname(pathname, dontApplySearchPath, directory, fileName, extension);
179 if (!dontApplySearchPath)
180 directory = getCurrentWorkingDirectory() + directory;
201 std::string directory, fileName, extension;
202 deconstructAbsolutePathname(pathname, directory, fileName, extension);
203 return directory + fileName + extension;
210 std::string absPath = getAbsolutePathname(dirPathname);
211 if (!absPath.empty() && absPath[absPath.size()-1] != getPathSeparatorChar())
212 absPath += getPathSeparatorChar();
219 static std::string getAbsolutePathnameUsingSpecifiedWorkingDirectory
220 (
const std::string& swd,
const std::string& pathname) {
221 std::string directory, fileName, extension;
222 deconstructPathnameUsingSpecifiedWorkingDirectory
223 (swd, pathname, directory, fileName, extension);
224 return directory + fileName + extension;
231 getAbsoluteDirectoryPathnameUsingSpecifiedWorkingDirectory
232 (
const std::string& swd,
const std::string& dirPathname) {
233 std::string absPath =
234 getAbsolutePathnameUsingSpecifiedWorkingDirectory(swd, dirPathname);
235 if (!absPath.empty() && absPath[absPath.size()-1] != getPathSeparatorChar())
236 absPath += getPathSeparatorChar();
242 static bool fileExists(
const std::string& pathname);
247 static std::string getDefaultInstallDir();
254 static std::string addDirectoryOffset(
const std::string& base,
255 const std::string& offset);
260 static std::string getInstallDir(
const std::string& envInstallDir,
261 const std::string& offsetFromDefaultInstallDir);
264 static std::string getThisExecutablePath();
267 static std::string getThisExecutableDirectory();
283 static bool getFunctionLibraryDirectory(
void* func,
284 std::string& absolutePathname);
292 static std::string getCurrentWorkingDirectory(
const std::string& drive=
"");
296 static std::string getRootDirectory(
const std::string& drive=
"");
299 static std::string getCurrentDriveLetter();
302 static std::string getCurrentDrive();
305 static bool environmentVariableExists(
const std::string& name);
311 static std::string getEnvironmentVariable(
const std::string& name);
315 static std::string getPathSeparator();
319 static char getPathSeparatorChar();
322 return c==
'/' || c==
'\\';
328 #endif // SimTK_SimTKCOMMON_PATHNAME_H_