AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
FileSystem.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx 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
27namespace 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
38 AGXCORE_EXPORT static const char* const PATH_SEPARATOR;
39
41 AGXCORE_EXPORT static const char* const UNIX_PATH_SEPARATOR;
42
44 AGXCORE_EXPORT static const char* const WINDOWS_PATH_SEPARATOR;
45
47 AGXCORE_EXPORT static const char* const PATH_DELIMITER;
48
50 AGXCORE_EXPORT static const char* const DLL_SUFFIX;
51
55 AGXCORE_EXPORT static FILE* openFile( const char* file, const char* mode );
56
60 AGXCORE_EXPORT static FILE* openFile( const agx::String& str, const char* mode );
61
66 AGXCORE_EXPORT static bool closeFile( FILE* stream );
67
72
79 static AGXCORE_EXPORT bool mkdir(const agx::String& path, bool recursive = false);
80
85 static AGXCORE_EXPORT bool scan(const agx::String& path, ScanCallback callback);
86
90 static AGXCORE_EXPORT bool isDir(const agx::String& path);
91
95 static AGXCORE_EXPORT bool isAbsolute(const agx::String& path);
96
100 static AGXCORE_EXPORT bool isLink( const agx::String& path );
101
105 static AGXCORE_EXPORT size_t size( const agx::String& path );
106
111 static AGXCORE_EXPORT bool exists(const agx::String& path);
112
117 static AGXCORE_EXPORT bool readable(const agx::String& path);
118
123 static AGXCORE_EXPORT bool writeable(const agx::String& path);
124
129
135 static AGXCORE_EXPORT agx::String mkTmpDirectory(const agx::String& parentDirectory, const agx::String& prefix);
136
142 static AGXCORE_EXPORT time_t compareDate(const agx::String& path1, const agx::String& path2);
143
144 static AGXCORE_EXPORT bool rename(const agx::String& oldPath, const agx::String& newPath);
145
146 static AGXCORE_EXPORT bool copy(const agx::String& source, const agx::String& destination);
147
148 static AGXCORE_EXPORT bool remove(const agx::String& path, bool recursive = false);
149
155
161
164
176
179
182
185
188
196 static AGXCORE_EXPORT size_t getFilesInDirectory(agx::StringVector& result, const agx::String& path, bool recursive = false);
197
207
208
211
218
223
228
235 static AGXCORE_EXPORT int stat(const agx::String& path, StatStruct* buf);
236
241
242 }; // struct FileSystem
243} // Namespace agxIO
#define AGXCORE_EXPORT
Templated callback with one argument.
Definition Callback.h:101
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 const char *const PATH_DELIMITER
Separator between paths in a list of paths, on unix: :, on windows ;.
Definition FileSystem.h:47
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 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 time_t compareDate(const agx::String &path1, const agx::String &path2)
static AGXCORE_EXPORT FILE * openFile(const agx::String &str, const char *mode)
Open a file.
static AGXCORE_EXPORT FILE * openFile(const char *file, const char *mode)
Open a file.
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:84
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 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 *const WINDOWS_PATH_SEPARATOR
Path separator under Windows: backlash.
Definition FileSystem.h:44
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 const char *const PATH_SEPARATOR
Separator between directories in a file path: on unix /, on windows backlash.
Definition FileSystem.h:38
static AGXCORE_EXPORT agx::String readFile(const agx::String &filename)
Read the contents of filename and return it as a String.
static AGXCORE_EXPORT size_t size(const agx::String &path)
static AGXCORE_EXPORT const char *const DLL_SUFFIX
Filetype for dynamically loaded libraries (dll / so / dylib)
Definition FileSystem.h:50
static AGXCORE_EXPORT const char *const UNIX_PATH_SEPARATOR
Path separator under UNIX /.
Definition FileSystem.h:41
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.