VR-Forces Development_Version 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 
81  static bool isAbsolutePath(const std::string& path);
82 
87  static bool exists(const std::string& path);
88 
93  static bool exists(const boost::filesystem::path& path);
94 
103  static bool equivalent(const std::string& path1, const std::string& path2);
104 
121  static std::string makeRelative(const std::string& root, const std::string& path);
122 
130  static std::string setExtension(std::string file, std::string ext);
131 
140  static std::string addExtension(std::string file, std::string ext);
141 
149  static std::string extension(const std::string& file, bool withDot=false);
150 
158  static std::string extensionCaseSensitive(std::string file, bool withDot=false);
159 
165  static std::string baseName(const std::string& file);
166 
173  static std::string directoryOfFile(const std::string& file);
174 
181  static std::string directoryOfPath(const std::string& file);
182 
189  static std::string rootDirectoryOfPath(const std::string& file);
190 
195  static std::string nativePath(const std::string& path);
196 
201  static DtUnicode nativePath(const DtUnicode& path);
202 
207  static bool is_directory(const std::string& path);
208 
213  static bool is_directory(const boost::filesystem::path& path);
214 
219  static bool deleteFile(const std::string& file);
220 
229  template <typename PathCollection>
230  static bool findFile(const std::string& filePathIn,
231  const PathCollection& paths, std::string& actualFilePathOut)
232  {
233  //Does the file exist.
234  if(DtVrvFilesystem::exists(filePathIn))
235  {
236  actualFilePathOut = filePathIn;
237  return true;
238  }
239 
240  //Else look for file in supplied paths.
241  typename PathCollection::const_iterator i = paths.begin();
242  typename PathCollection::const_iterator e = paths.end();
243  for(; i != e; ++i)
244  {
245  if(findFileInPath(filePathIn, *i, actualFilePathOut))
246  {
247  return true;
248  }
249  }
250  return false;
251  }
252 
263  static bool findFileInPath(const std::string& filePathIn,
264  const std::string& path, std::string& actualFilePathOut);
265  };
266 }

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)