VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtVrvFilesystem.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2018 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 
140  static std::string fileName(const std::string& path);
141 
146  static bool exists(const boost::filesystem::path& path);
147 
156  static bool equivalent(const std::string& path1, const std::string& path2);
157 
174  static std::string makeRelative(const std::string& root, const std::string& path);
175 
183  static std::string setExtension(std::string file, std::string ext);
184 
193  static std::string addExtension(std::string file, std::string ext);
194 
202  static std::string extension(const std::string& file, bool withDot=false);
203 
211  static std::string extensionCaseSensitive(std::string file, bool withDot=false);
212 
218  static std::string baseName(const std::string& file);
219 
226  static std::string directoryOfFile(const std::string& file);
227 
234  static std::string directoryOfPath(const std::string& file);
235 
242  static std::string rootDirectoryOfPath(const std::string& file);
243 
248  static std::string nativePath(const std::string& path);
249 
254  static DtUnicode nativePath(const DtUnicode& path);
255 
260  static bool is_directory(const std::string& path);
261 
266  static bool is_directory(const boost::filesystem::path& path);
267 
272  static bool deleteFile(const std::string& file);
273 
278  static bool deleteDirectory(const std::string& dir);
279 
288  template <typename PathCollection>
289  static bool findFile(const std::string& filePathIn,
290  const PathCollection& paths, std::string& actualFilePathOut)
291  {
292  //Does the file exist.
293  if(DtVrvFilesystem::exists(filePathIn))
294  {
295  actualFilePathOut = filePathIn;
296  return true;
297  }
298 
299  //Else look for file in supplied paths.
300  typename PathCollection::const_iterator i = paths.begin();
301  typename PathCollection::const_iterator e = paths.end();
302  for(; i != e; ++i)
303  {
304  if(findFileInPath(filePathIn, *i, actualFilePathOut))
305  {
306  return true;
307  }
308  }
309  return false;
310  }
311 
322  static bool findFileInPath(const std::string& filePathIn,
323  const std::string& path, std::string& actualFilePathOut);
324 
326  static unsigned int makeAndXorHash(const std::string& filePath);
327 
329  static size_t ts_fileSize(const std::string& strFileName);
330 
332  static bool ts_fileExists(const std::string& strFileName);
333 
336  static void ts_readFileIntoBuffer(const std::string& strFileName, unsigned char*& pData, size_t& size);
337  };
338 }
A unicode string. DtUnicode stores a UTF-16 encoded unicode string. Code Point, a Unicode character...
Definition: DtUnicode.h:33
#define DT_DLL_VRVUTIL
Definition: vrvUtil.h:34
voidpf void uLong size
Definition: ioapi.h:39
static bool findFile(const std::string &filePathIn, const PathCollection &paths, std::string &actualFilePathOut)
Find a file in a list of paths. Iterate through a list of paths and attempt to find a file within one...
Definition: DtVrvFilesystem.h:289
static bool exists(const std::string &path)
Check if the given path is exists.
The DtVrvFilesystem is a wrapper around boost functions that are know to throw exceptions. These functions are all reentrent* however the working directory should not be changed.
Definition: DtVrvFilesystem.h:22

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)