AGX Dynamics  2.35.0.1
FileSystem.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agx/agx.h>
20 #include <agx/agxCore_export.h>
21 #include <agx/Callback.h>
22 #include <agx/String.h>
23 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
24 #include <sys/stat.h>
25 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
26 
27 namespace agxIO
28 {
29  struct FileSystem {
30 
31  #ifdef _MSC_VER
32  typedef struct _stat64 StatStruct;
33  #else
34  typedef struct stat StatStruct;
35  #endif
36 
37 #ifndef SWIG
39  AGXCORE_EXPORT static const char* PATH_SEPARATOR;
40 
42  AGXCORE_EXPORT static const char* UNIX_PATH_SEPARATOR;
43 
46 
48  AGXCORE_EXPORT static const char* PATH_DELIMITER;
49 
51  AGXCORE_EXPORT static const char* DLL_SUFFIX;
52 #endif
53 
57  AGXCORE_EXPORT static FILE* openFile( const char* file, const char* mode );
58 
62  AGXCORE_EXPORT static FILE* openFile( const agx::String& str, const char* mode );
63 
68  AGXCORE_EXPORT static bool closeFile( FILE* stream );
69 
73  static AGXCORE_EXPORT agx::String readFile( const agx::String& filename );
74 
81  static AGXCORE_EXPORT bool mkdir(const agx::String& path, bool recursive = false);
82 
87  static AGXCORE_EXPORT bool scan(const agx::String& path, ScanCallback callback);
88 
92  static AGXCORE_EXPORT bool isDir(const agx::String& path);
93 
97  static AGXCORE_EXPORT bool isAbsolute(const agx::String& path);
98 
102  static AGXCORE_EXPORT bool isLink( const agx::String& path );
103 
107  static AGXCORE_EXPORT size_t size( const agx::String& path );
108 
113  static AGXCORE_EXPORT bool exists(const agx::String& path);
114 
119  static AGXCORE_EXPORT bool readable(const agx::String& path);
120 
125  static AGXCORE_EXPORT bool writeable(const agx::String& path);
126 
131 
137  static AGXCORE_EXPORT agx::String mkTmpDirectory(const agx::String& parentDirectory, const agx::String& prefix);
138 
144  static AGXCORE_EXPORT time_t compareDate(const agx::String& path1, const agx::String& path2);
145 
146  static AGXCORE_EXPORT bool rename(const agx::String& oldPath, const agx::String& newPath);
147 
148  static AGXCORE_EXPORT bool copy(const agx::String& source, const agx::String& destination);
149 
150  static AGXCORE_EXPORT bool remove(const agx::String& path, bool recursive = false);
151 
157 
163 
166 
178 
181 
184 
187 
190 
198  static AGXCORE_EXPORT size_t getFilesInDirectory(agx::StringVector& result, const agx::String& path, bool recursive = false);
199 
208  static AGXCORE_EXPORT agx::String combinePath(const agx::String& path1, const agx::String& path2);
209 
210 
213 
219  static agx::String AGXCORE_EXPORT getAbsolutePath( const agx::String& relativePath );
220 
225 
230 
237  static AGXCORE_EXPORT int stat(const agx::String& path, StatStruct* buf);
238 
243 
244  }; // struct FileSystem
245 } // Namespace agxIO
#define AGXCORE_EXPORT
The agxIO namespace contains classes for reading, writing and finding files.
Definition: Material.h:42
static AGXCORE_EXPORT bool mkdir(const agx::String &path, bool recursive=false)
Creates a directory on the host file system.
static AGXCORE_EXPORT bool rename(const agx::String &oldPath, const agx::String &newPath)
static AGXCORE_EXPORT agx::String mkTmpDirectory(const agx::String &parentDirectory, const agx::String &prefix)
static AGXCORE_EXPORT bool scan(const agx::String &path, ScanCallback callback)
static AGXCORE_EXPORT const char * DLL_SUFFIX
Filetype for dynamically loaded libraries (dll / so / dylib)
Definition: FileSystem.h:51
static AGXCORE_EXPORT agx::String getFileWithoutExtension(const agx::String &filePath)
static AGXCORE_EXPORT bool isLink(const agx::String &path)
static AGXCORE_EXPORT agx::String getTmpFilename()
static AGXCORE_EXPORT bool closeFile(FILE *stream)
Close the FILE* stream.
static AGXCORE_EXPORT agx::String mkTmpDirectory(const agx::String &prefix="")
Create a temporary directory.
static AGXCORE_EXPORT agx::String convertWindowsFilePathToUnix(const agx::String &windowsStyle)
static AGXCORE_EXPORT FILE * openFile(const char *file, const char *mode)
Open a file.
static AGXCORE_EXPORT time_t compareDate(const agx::String &path1, const agx::String &path2)
static AGXCORE_EXPORT bool copy(const agx::String &source, const agx::String &destination)
static AGXCORE_EXPORT agx::String convertToColladaFilePath(const agx::String &filePath)
Take a filepath, convert it to Unix format (using UNIX_PATH_SEPARATOR) and finally convert it to a fo...
static AGXCORE_EXPORT agx::String getDirectory(const agx::String &filePath)
agx::Callback1< const agx::String & > ScanCallback
Scan a directory.
Definition: FileSystem.h:86
static agx::String AGXCORE_EXPORT getAbsolutePath(const agx::String &relativePath)
If is a relative path (isabsolute() returns false), the path will be expanded into a full path using ...
static AGXCORE_EXPORT bool isDir(const agx::String &path)
Test if a path is a directory.
static AGXCORE_EXPORT int stat(const agx::String &path, StatStruct *buf)
Wrapper around the stat-function to work around a bug in Visual Studio when passing an empty string t...
static AGXCORE_EXPORT bool writeable(const agx::String &path)
Test if a path exists and is writeable.
static AGXCORE_EXPORT agx::String getFileExtension(const agx::String &filePath)
static AGXCORE_EXPORT bool readable(const agx::String &path)
Test if a path exists and is readable.
struct stat StatStruct
Definition: FileSystem.h:34
static agx::String AGXCORE_EXPORT getPath(const agx::String &path)
\ return the path without any ending filename (only the directory/disk) in native format
static AGXCORE_EXPORT agx::String getFileWithExtension(const agx::String &filePath)
static AGXCORE_EXPORT const char * PATH_DELIMITER
Separator between paths in a list of paths, on unix: ":", on windows ";".
Definition: FileSystem.h:48
static agx::String AGXCORE_EXPORT getCurrentWorkingDirectory()
static AGXCORE_EXPORT bool isAbsolute(const agx::String &path)
static AGXCORE_EXPORT agx::String getSystemTmpDirectory()
static AGXCORE_EXPORT const char * PATH_SEPARATOR
Separator between directories in a file path: on unix "/", on windows "\\".
Definition: FileSystem.h:39
static AGXCORE_EXPORT agx::String combinePath(const agx::String &path1, const agx::String &path2)
Combine two paths with a separator.
static AGXCORE_EXPORT size_t getFilesInDirectory(agx::StringVector &result, const agx::String &path, bool recursive=false)
Returns a list of all files in a directory.
static AGXCORE_EXPORT bool exists(const agx::String &path)
Test if a path exists.
static AGXCORE_EXPORT agx::String readFile(const agx::String &filename)
Read the contents of filename and return it as a String.
static AGXCORE_EXPORT const char * UNIX_PATH_SEPARATOR
Path separator under UNIX "/".
Definition: FileSystem.h:42
static AGXCORE_EXPORT size_t size(const agx::String &path)
/return The size of the file.
static AGXCORE_EXPORT FILE * openFile(const agx::String &str, const char *mode)
Open a file.
static AGXCORE_EXPORT agx::String convertToNativeFilePath(const agx::String &filePath)
static AGXCORE_EXPORT agx::String convertUnixFilePathToWindows(const agx::String &unixStyle)
static AGXCORE_EXPORT bool remove(const agx::String &path, bool recursive=false)
static bool AGXCORE_EXPORT setCurrentWorkingDirectory(const agx::String &path)
Set the current working directory.
static AGXCORE_EXPORT const char * WINDOWS_PATH_SEPARATOR
Path separator under Windows "\\".
Definition: FileSystem.h:45