VR-Vantage API Documentation
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/vrvUtil.h>
12 #include <vrvUtil/DtUnicode.h>
13 #include <boost/filesystem.hpp>
14 #include <string>
15 
16 namespace makVrv
17 {
24  {
25 
26  public:
27 
32  static bool createAllDirectories(const std::string& dirPath);
33 
43  static std::string absolutePath(const std::string& path);
44 
54  static DtUnicode absolutePath(const DtUnicode& path);
55 
64  static std::string cleanPath(const std::string& path);
65 
74  static DtUnicode cleanPath(const DtUnicode& path);
75 
82  static bool isAbsolutePath(const std::string& path);
83 
88  static bool exists(const std::string& path);
89 
94  static bool exists(const boost::filesystem::path& path);
95 
104  static bool equivalent(const std::string& path1, const std::string& path2);
105 
122  static std::string makeRelative(const std::string& root, const std::string& path);
123 
131  static std::string setExtension(std::string file, std::string ext);
132 
141  static std::string addExtension(std::string file, std::string ext);
142 
150  static std::string extension(const std::string& file, bool withDot=false);
151 
159  static std::string extensionCaseSensitive(std::string file, bool withDot=false);
160 
166  static std::string baseName(const std::string& file);
167 
174  static std::string directoryOfFile(const std::string& file);
175 
182  static std::string directoryOfPath(const std::string& file);
183 
190  static std::string rootDirectoryOfPath(const std::string& file);
191 
196  static std::string nativePath(const std::string& path);
197 
202  static DtUnicode nativePath(const DtUnicode& path);
203 
208  static bool is_directory(const std::string& path);
209 
214  static bool is_directory(const boost::filesystem::path& path);
215 
220  static bool deleteFile(const std::string& file);
221 
230  template <typename PathCollection>
231  static bool findFile(const std::string& filePathIn,
232  const PathCollection& paths, std::string& actualFilePathOut)
233  {
234  //Does the file exist.
235  if(DtVrvFilesystem::exists(filePathIn))
236  {
237  actualFilePathOut = filePathIn;
238  return true;
239  }
240 
241  //Else look for file in supplied paths.
242  typename PathCollection::const_iterator i = paths.begin();
243  typename PathCollection::const_iterator e = paths.end();
244  for(; i != e; ++i)
245  {
246  if(findFileInPath(filePathIn, *i, actualFilePathOut))
247  {
248  return true;
249  }
250  }
251  return false;
252  }
253 
264  static bool findFileInPath(const std::string& filePathIn,
265  const std::string& path, std::string& actualFilePathOut);
266  };
267 }


Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)