![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2012 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 00009 00010 #pragma once 00011 #include <vrvUtil/vrvUtil.h> 00012 #include <vrvUtil/DtUnicode.h> 00013 #include <boost/filesystem.hpp> 00014 #include <string> 00015 00016 namespace makVrv 00017 { 00023 class DT_DLL_VRVUTIL DtVrvFilesystem 00024 { 00025 00026 public: 00027 00032 static bool createAllDirectories(const std::string& dirPath); 00033 00043 static std::string absolutePath(const std::string& path); 00044 00054 static DtUnicode absolutePath(const DtUnicode& path); 00055 00064 static std::string cleanPath(const std::string& path); 00065 00074 static DtUnicode cleanPath(const DtUnicode& path); 00075 00082 static bool isAbsolutePath(const std::string& path); 00083 00088 static bool exists(const std::string& path); 00089 00094 static bool exists(const boost::filesystem::path& path); 00095 00104 static bool equivalent(const std::string& path1, const std::string& path2); 00105 00122 static std::string makeRelative(const std::string& root, const std::string& path); 00123 00131 static std::string setExtension(std::string file, std::string ext); 00132 00141 static std::string addExtension(std::string file, std::string ext); 00142 00150 static std::string extension(const std::string& file, bool withDot=false); 00151 00159 static std::string extensionCaseSensitive(std::string file, bool withDot=false); 00160 00166 static std::string baseName(const std::string& file); 00167 00174 static std::string directoryOfFile(const std::string& file); 00175 00182 static std::string directoryOfPath(const std::string& file); 00183 00190 static std::string rootDirectoryOfPath(const std::string& file); 00191 00196 static std::string nativePath(const std::string& path); 00197 00202 static DtUnicode nativePath(const DtUnicode& path); 00203 00208 static bool is_directory(const std::string& path); 00209 00214 static bool is_directory(const boost::filesystem::path& path); 00215 00220 static bool deleteFile(const std::string& file); 00221 00230 template <typename PathCollection> 00231 static bool findFile(const std::string& filePathIn, 00232 const PathCollection& paths, std::string& actualFilePathOut) 00233 { 00234 //Does the file exist. 00235 if(DtVrvFilesystem::exists(filePathIn)) 00236 { 00237 actualFilePathOut = filePathIn; 00238 return true; 00239 } 00240 00241 //Else look for file in supplied paths. 00242 typename PathCollection::const_iterator i = paths.begin(); 00243 typename PathCollection::const_iterator e = paths.end(); 00244 for(; i != e; ++i) 00245 { 00246 if(findFileInPath(filePathIn, *i, actualFilePathOut)) 00247 { 00248 return true; 00249 } 00250 } 00251 return false; 00252 } 00253 00264 static bool findFileInPath(const std::string& filePathIn, 00265 const std::string& path, std::string& actualFilePathOut); 00266 }; 00267 }