AGX Dynamics  2.37.3.2
agxIO::FileSystem Struct Reference

#include <FileSystem.h>

Public Types

typedef agx::Callback1< const agx::String & > ScanCallback
 Scan a directory. More...
 
typedef struct stat StatStruct
 

Static Public Member Functions

static AGXCORE_EXPORT bool closeFile (FILE *stream)
 Close the FILE* stream. More...
 
static AGXCORE_EXPORT agx::String combinePath (const agx::String &path1, const agx::String &path2)
 Combine two paths with a separator. More...
 
static AGXCORE_EXPORT time_t compareDate (const agx::String &path1, const agx::String &path2)
 
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 format that Collada DAE api accepts. More...
 
static AGXCORE_EXPORT agx::String convertToNativeFilePath (const agx::String &filePath)
 
static AGXCORE_EXPORT agx::String convertUnixFilePathToWindows (const agx::String &unixStyle)
 
static AGXCORE_EXPORT agx::String convertWindowsFilePathToUnix (const agx::String &windowsStyle)
 
static AGXCORE_EXPORT bool copy (const agx::String &source, const agx::String &destination)
 
static AGXCORE_EXPORT bool exists (const agx::String &path)
 Test if a path exists. More...
 
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 current working directory. More...
 
static agx::String AGXCORE_EXPORT getCurrentWorkingDirectory ()
 
static AGXCORE_EXPORT agx::String getDirectory (const agx::String &filePath)
 
static AGXCORE_EXPORT agx::String getFileExtension (const agx::String &filePath)
 
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. More...
 
static AGXCORE_EXPORT agx::String getFileWithExtension (const agx::String &filePath)
 
static AGXCORE_EXPORT agx::String getFileWithoutExtension (const agx::String &filePath)
 
static agx::String AGXCORE_EXPORT getPath (const agx::String &path)
 \ return the path without any ending filename (only the directory/disk) in native format More...
 
static AGXCORE_EXPORT agx::String getSystemTmpDirectory ()
 
static AGXCORE_EXPORT agx::String getTmpFilename ()
 
static AGXCORE_EXPORT bool isAbsolute (const agx::String &path)
 
static AGXCORE_EXPORT bool isDir (const agx::String &path)
 Test if a path is a directory. More...
 
static AGXCORE_EXPORT bool isLink (const agx::String &path)
 
static AGXCORE_EXPORT bool mkdir (const agx::String &path, bool recursive=false)
 Creates a directory on the host file system. More...
 
static AGXCORE_EXPORT agx::String mkTmpDirectory (const agx::String &prefix="")
 Create a temporary directory. More...
 
static AGXCORE_EXPORT agx::String mkTmpDirectory (const agx::String &parentDirectory, const agx::String &prefix)
 
static AGXCORE_EXPORT FILE * openFile (const char *file, const char *mode)
 Open a file. More...
 
static AGXCORE_EXPORT FILE * openFile (const agx::String &str, const char *mode)
 Open a file. More...
 
static AGXCORE_EXPORT bool readable (const agx::String &path)
 Test if a path exists and is readable. More...
 
static AGXCORE_EXPORT agx::String readFile (const agx::String &filename)
 Read the contents of filename and return it as a String. More...
 
static AGXCORE_EXPORT bool remove (const agx::String &path, bool recursive=false)
 
static AGXCORE_EXPORT bool rename (const agx::String &oldPath, const agx::String &newPath)
 
static AGXCORE_EXPORT bool scan (const agx::String &path, ScanCallback callback)
 
static bool AGXCORE_EXPORT setCurrentWorkingDirectory (const agx::String &path)
 Set the current working directory. More...
 
static AGXCORE_EXPORT size_t size (const agx::String &path)
 /return The size of the file. More...
 
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 to stat. More...
 
static AGXCORE_EXPORT bool writeable (const agx::String &path)
 Test if a path exists and is writeable. More...
 

Static Public Attributes

static AGXCORE_EXPORT const char *const DLL_SUFFIX
 Filetype for dynamically loaded libraries (dll / so / dylib) More...
 
static AGXCORE_EXPORT const char *const PATH_DELIMITER
 Separator between paths in a list of paths, on unix: :, on windows ;. More...
 
static AGXCORE_EXPORT const char *const PATH_SEPARATOR
 Separator between directories in a file path: on unix /, on windows backlash. More...
 
static AGXCORE_EXPORT const char *const UNIX_PATH_SEPARATOR
 Path separator under UNIX /. More...
 
static AGXCORE_EXPORT const char *const WINDOWS_PATH_SEPARATOR
 Path separator under Windows: backlash. More...
 

Detailed Description

Definition at line 29 of file FileSystem.h.

Member Typedef Documentation

◆ ScanCallback

Scan a directory.

Definition at line 84 of file FileSystem.h.

◆ StatStruct

Definition at line 34 of file FileSystem.h.

Member Function Documentation

◆ closeFile()

static AGXCORE_EXPORT bool agxIO::FileSystem::closeFile ( FILE *  stream)
static

Close the FILE* stream.

Returns
true on success.

◆ combinePath()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::combinePath ( const agx::String &  path1,
const agx::String &  path2 
)
static

Combine two paths with a separator.

This method will return the path in native format Any double occurrence of path separators will be removed.

Parameters
path1- First path to be combined
path2- Second path to be combined
Returns
path1 and path2 combined with a separator

◆ compareDate()

static AGXCORE_EXPORT time_t agxIO::FileSystem::compareDate ( const agx::String &  path1,
const agx::String &  path2 
)
static
Returns
difference between last modified time of the two files path1 and path 2, OR 0 if none of the two files could be accessed OR 1 if path1 could not be accessed OR -1 of path2 could not be accessed.

◆ convertToColladaFilePath()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::convertToColladaFilePath ( const agx::String &  filePath)
static

Take a filepath, convert it to Unix format (using UNIX_PATH_SEPARATOR) and finally convert it to a format that Collada DAE api accepts.

For windows this means that "c:\path" -> "/c:/path"

If the string "://" can be found in filePath then no conversion will take place, as it assumes that the path is already in the correct format.

Returns
filePath converted to collada compliant file path format.

◆ convertToNativeFilePath()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::convertToNativeFilePath ( const agx::String &  filePath)
static
Returns
filepath converted to the current platforms filepath specification

◆ convertUnixFilePathToWindows()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::convertUnixFilePathToWindows ( const agx::String &  unixStyle)
static
Parameters
unixStyle- Path in unix style (with / separators)
Returns
path in Windows style (with \)

◆ convertWindowsFilePathToUnix()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::convertWindowsFilePathToUnix ( const agx::String &  windowsStyle)
static
Parameters
windowsStyle- Path in windows style (with \ separators)
Returns
path in Unix style (with )

◆ copy()

static AGXCORE_EXPORT bool agxIO::FileSystem::copy ( const agx::String &  source,
const agx::String &  destination 
)
static

◆ exists()

static AGXCORE_EXPORT bool agxIO::FileSystem::exists ( const agx::String &  path)
static

Test if a path exists.

Returns
true if file exists.

◆ getAbsolutePath()

static agx::String AGXCORE_EXPORT agxIO::FileSystem::getAbsolutePath ( const agx::String &  relativePath)
static

If is a relative path (isabsolute() returns false), the path will be expanded into a full path using current working directory.

Returns
relativePath expanded into an absolute path

◆ getCurrentWorkingDirectory()

static agx::String AGXCORE_EXPORT agxIO::FileSystem::getCurrentWorkingDirectory ( )
static
Returns
The current working directory in native path format.

◆ getDirectory()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::getDirectory ( const agx::String &  filePath)
static
Returns
the file system directory containing the file

◆ getFileExtension()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::getFileExtension ( const agx::String &  filePath)
static
Returns
the extension (without .) of the file

◆ getFilesInDirectory()

static AGXCORE_EXPORT size_t agxIO::FileSystem::getFilesInDirectory ( agx::StringVector &  result,
const agx::String &  path,
bool  recursive = false 
)
static

Returns a list of all files in a directory.

Parameters
result- The vector that will be populated with all files in path.
path- The path to the directory where files will be found. If empty current directory ("./") will be used.
recursive- If true, a recursive search for files will be performed.
Returns
number of found files

◆ getFileWithExtension()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::getFileWithExtension ( const agx::String &  filePath)
static
Returns
the filename including file extension (no path)

◆ getFileWithoutExtension()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::getFileWithoutExtension ( const agx::String &  filePath)
static
Returns
the filename only (no extension no path)

◆ getPath()

static agx::String AGXCORE_EXPORT agxIO::FileSystem::getPath ( const agx::String &  path)
static

\ return the path without any ending filename (only the directory/disk) in native format

◆ getSystemTmpDirectory()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::getSystemTmpDirectory ( )
static
Returns
A platform specific directory for temporary files.

◆ getTmpFilename()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::getTmpFilename ( )
static
Returns
a string with a unique filename including a path which can be used to create a temporary file

◆ isAbsolute()

static AGXCORE_EXPORT bool agxIO::FileSystem::isAbsolute ( const agx::String &  path)
static
Returns
true if the given path is an absolute path.

◆ isDir()

static AGXCORE_EXPORT bool agxIO::FileSystem::isDir ( const agx::String &  path)
static

Test if a path is a directory.

◆ isLink()

static AGXCORE_EXPORT bool agxIO::FileSystem::isLink ( const agx::String &  path)
static
Returns
true if the path is a link. Under windows this method always return false.

◆ mkdir()

static AGXCORE_EXPORT bool agxIO::FileSystem::mkdir ( const agx::String &  path,
bool  recursive = false 
)
static

Creates a directory on the host file system.

Parameters
path- Path to the directory that will be created
recursive- If true, non existing directories in the path will be created, not just the last.
Returns
true if successful

◆ mkTmpDirectory() [1/2]

static AGXCORE_EXPORT agx::String agxIO::FileSystem::mkTmpDirectory ( const agx::String &  prefix = "")
static

Create a temporary directory.

Returns
Empty string if failed

◆ mkTmpDirectory() [2/2]

static AGXCORE_EXPORT agx::String agxIO::FileSystem::mkTmpDirectory ( const agx::String &  parentDirectory,
const agx::String &  prefix 
)
static

◆ openFile() [1/2]

static AGXCORE_EXPORT FILE* agxIO::FileSystem::openFile ( const char *  file,
const char *  mode 
)
static

Open a file.

The filename should be in ascii or utf-8 format.

◆ openFile() [2/2]

static AGXCORE_EXPORT FILE* agxIO::FileSystem::openFile ( const agx::String &  str,
const char *  mode 
)
static

Open a file.

The filename should be in ascii or utf-8 format.

◆ readable()

static AGXCORE_EXPORT bool agxIO::FileSystem::readable ( const agx::String &  path)
static

Test if a path exists and is readable.

Returns
true if path exists and is readable.

◆ readFile()

static AGXCORE_EXPORT agx::String agxIO::FileSystem::readFile ( const agx::String &  filename)
static

Read the contents of filename and return it as a String.

◆ remove()

static AGXCORE_EXPORT bool agxIO::FileSystem::remove ( const agx::String &  path,
bool  recursive = false 
)
static

◆ rename()

static AGXCORE_EXPORT bool agxIO::FileSystem::rename ( const agx::String &  oldPath,
const agx::String &  newPath 
)
static

◆ scan()

static AGXCORE_EXPORT bool agxIO::FileSystem::scan ( const agx::String &  path,
ScanCallback  callback 
)
static

◆ setCurrentWorkingDirectory()

static bool AGXCORE_EXPORT agxIO::FileSystem::setCurrentWorkingDirectory ( const agx::String &  path)
static

Set the current working directory.

◆ size()

static AGXCORE_EXPORT size_t agxIO::FileSystem::size ( const agx::String &  path)
static

/return The size of the file.

◆ stat()

static AGXCORE_EXPORT int agxIO::FileSystem::stat ( const agx::String &  path,
StatStruct *  buf 
)
static

Wrapper around the stat-function to work around a bug in Visual Studio when passing an empty string to stat.

Parameters
pathThe path to the file (c-string in original stat)
bufThe pointer to a preallocated stat-struct (see original stat-function).

◆ writeable()

static AGXCORE_EXPORT bool agxIO::FileSystem::writeable ( const agx::String &  path)
static

Test if a path exists and is writeable.

Returns
true if path exists and is writeable.

Member Data Documentation

◆ DLL_SUFFIX

AGXCORE_EXPORT const char* const agxIO::FileSystem::DLL_SUFFIX
static

Filetype for dynamically loaded libraries (dll / so / dylib)

Definition at line 50 of file FileSystem.h.

◆ PATH_DELIMITER

AGXCORE_EXPORT const char* const agxIO::FileSystem::PATH_DELIMITER
static

Separator between paths in a list of paths, on unix: :, on windows ;.

Definition at line 47 of file FileSystem.h.

◆ PATH_SEPARATOR

AGXCORE_EXPORT const char* const agxIO::FileSystem::PATH_SEPARATOR
static

Separator between directories in a file path: on unix /, on windows backlash.

Definition at line 38 of file FileSystem.h.

◆ UNIX_PATH_SEPARATOR

AGXCORE_EXPORT const char* const agxIO::FileSystem::UNIX_PATH_SEPARATOR
static

Path separator under UNIX /.

Definition at line 41 of file FileSystem.h.

◆ WINDOWS_PATH_SEPARATOR

AGXCORE_EXPORT const char* const agxIO::FileSystem::WINDOWS_PATH_SEPARATOR
static

Path separator under Windows: backlash.

Definition at line 44 of file FileSystem.h.


The documentation for this struct was generated from the following file: