VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtVrvFilesystem.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2012 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 #include <vrvUtil/DtUnicode.h>
12 #include <boost/filesystem.hpp>
13 #include <string>
14 
15 namespace makVrv
16 {
23  {
24 
25  public:
26 
31  static bool createAllDirectories(const std::string& dirPath);
32 
42  static std::string absolutePath(const std::string& path);
43 
53  static DtUnicode absolutePath(const DtUnicode& path);
54 
63  static std::string cleanPath(const std::string& path);
64 
73  static DtUnicode cleanPath(const DtUnicode& path);
74 
87  static bool getFilePathsWithExtension(const std::string& rootDir,
88  const std::string& ext, std::vector<std::string>& ret);
89 
102  static bool getFilePathsWithExtension(const std::vector<std::string>& fileOrDirVec,
103  const std::string& ext, std::vector<std::string>& ret);
104 
113  static bool getFilePathsInDir(const std::string& rootDir,
114  std::vector<std::string>& ret);
115 
122  static bool dirExistsNotEmpty(const std::string& rootDir);
123 
130  static bool isAbsolutePath(const std::string& path);
131 
136  static bool exists(const std::string& path);
137 
142  static bool exists(const boost::filesystem::path& path);
143 
152  static bool equivalent(const std::string& path1, const std::string& path2);
153 
170  static std::string makeRelative(const std::string& root, const std::string& path);
171 
179  static std::string setExtension(std::string file, std::string ext);
180 
189  static std::string addExtension(std::string file, std::string ext);
190 
198  static std::string extension(const std::string& file, bool withDot=false);
199 
207  static std::string extensionCaseSensitive(std::string file, bool withDot=false);
208 
214  static std::string baseName(const std::string& file);
215 
222  static std::string directoryOfFile(const std::string& file);
223 
230  static std::string directoryOfPath(const std::string& file);
231 
238  static std::string rootDirectoryOfPath(const std::string& file);
239 
244  static std::string nativePath(const std::string& path);
245 
250  static DtUnicode nativePath(const DtUnicode& path);
251 
256  static bool is_directory(const std::string& path);
257 
262  static bool is_directory(const boost::filesystem::path& path);
263 
268  static bool deleteFile(const std::string& file);
269 
274  static bool deleteDirectory(const std::string& dir);
275 
284  template <typename PathCollection>
285  static bool findFile(const std::string& filePathIn,
286  const PathCollection& paths, std::string& actualFilePathOut)
287  {
288  //Does the file exist.
289  if(DtVrvFilesystem::exists(filePathIn))
290  {
291  actualFilePathOut = filePathIn;
292  return true;
293  }
294 
295  //Else look for file in supplied paths.
296  typename PathCollection::const_iterator i = paths.begin();
297  typename PathCollection::const_iterator e = paths.end();
298  for(; i != e; ++i)
299  {
300  if(findFileInPath(filePathIn, *i, actualFilePathOut))
301  {
302  return true;
303  }
304  }
305  return false;
306  }
307 
318  static bool findFileInPath(const std::string& filePathIn,
319  const std::string& path, std::string& actualFilePathOut);
320  };
321 }

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)