VR-Forces 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) 2025 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 #include <set>
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 
88  static bool getFilePathsWithExtension(const std::string& rootDir,
89  const std::string& ext, std::vector<std::string>& ret);
90 
103  static bool getFilePathsWithExtension(const std::vector<std::string>& fileOrDirVec,
104  const std::string& ext, std::vector<std::string>& ret);
105 
114  static bool getFilePathsInDir(const std::string& rootDir,
115  std::vector<std::string>& ret);
116 
123  static bool dirExistsNotEmpty(const std::string& rootDir);
124 
131  static bool isAbsolutePath(const std::string& path);
132 
137  static bool exists(const std::string& path);
138 
141  static std::string fileName(const std::string& path);
142 
147  static bool exists(const boost::filesystem::path& path);
148 
157  static bool equivalent(const std::string& path1, const std::string& path2);
158 
175  static std::string makeRelative(const std::string& root, const std::string& path);
176 
184  static std::string setExtension(std::string file, std::string ext);
185 
194  static std::string addExtension(std::string file, std::string ext);
195 
203  static std::string extension(const std::string& file, bool withDot=false);
204 
212  static std::string extensionCaseSensitive(std::string file, bool withDot=false);
213 
219  static std::string baseName(const std::string& file);
220 
227  static std::string directoryOfFile(const std::string& file);
228 
235  static std::string directoryOfPath(const std::string& file);
236 
243  static std::string rootDirectoryOfPath(const std::string& file);
244 
249  static std::string nativePath(const std::string& path);
250 
255  static DtUnicode nativePath(const DtUnicode& path);
256 
268  static std::string canonicalPath( const std::string& path );
269  static DtUnicode canonicalPath( const DtUnicode& path );
271 
276  static bool is_directory(const std::string& path);
277 
282  static bool is_directory(const boost::filesystem::path& path);
283 
288  static bool deleteFile(const std::string& file);
289 
294  static bool deleteDirectory(const std::string& dir);
295 
300  static bool deleteDirectoryContents(const boost::filesystem::path& dir);
301 
307  static bool deleteDirectoryContentsWithIgnoreFilter(const boost::filesystem::path& dir, const std::set<std::string>& ignoreFilter);
308 
317  template <typename PathCollection>
318  static bool findFile(const std::string& filePathIn,
319  const PathCollection& paths, std::string& actualFilePathOut)
320  {
321  //Does the file exist.
322  if(DtVrvFilesystem::exists(filePathIn))
323  {
324  actualFilePathOut = filePathIn;
325  return true;
326  }
327 
328  //Else look for file in supplied paths.
329  typename PathCollection::const_iterator i = paths.begin();
330  typename PathCollection::const_iterator e = paths.end();
331  for(; i != e; ++i)
332  {
333  if(findFileInPath(filePathIn, *i, actualFilePathOut))
334  {
335  return true;
336  }
337  }
338  return false;
339  }
340 
351  static bool findFileInPath(const std::string& filePathIn,
352  const std::string& path, std::string& actualFilePathOut);
353 
355  static unsigned int makeAndXorHash(const std::string& filePath);
356 
358  static size_t ts_fileSize(const std::string& strFileName);
359 
361  static bool ts_fileExists(const std::string& strFileName);
362 
365  static void ts_readFileIntoBuffer(const std::string& strFileName, unsigned char*& pData, size_t& size);
366  };
367 }
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:318
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:23

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)