nCine 2022.04.r504-20bd01e
A cross-platform 2D game engine
Loading...
Searching...
No Matches
Classes | Public Types | Static Public Member Functions | Static Public Attributes | Friends | List of all members
ncine::FileSystem Class Reference

File system related methods. More...

#include <FileSystem.h>

Classes

class  Directory
 The class that handles directory traversal. More...
 
struct  FileDate
 

Public Types

enum  Permission { READ = 1 , WRITE = 2 , EXECUTE = 4 }
 The available permissions to check or set.
 

Static Public Member Functions

static nctl::String joinPath (const nctl::String &first, const nctl::String &second)
 Joins together two path components.
 
static nctl::String absoluteJoinPath (const nctl::String &first, const nctl::String &second)
 Returns the absolute path after joining together two path components.
 
static nctl::String dirName (const char *path)
 Returns the path up to, but not including, the final separator.
 
static nctl::String baseName (const char *path)
 Returns the path component after the final separator.
 
static nctl::String absolutePath (const char *path)
 Returns an absolute path from a relative one.
 
static const char * extension (const char *path)
 Returns the extension position in the string or nullptr if it is not found.
 
static bool hasExtension (const char *path, const char *extension)
 Returns true if the path has the specified extension (case-insensitive comparison)
 
static bool fixExtension (nctl::String &path, const char *extension)
 Returns true if the path has been changed to fix the extension.
 
static unsigned long logicalDrives ()
 Returns a bitmask representing the currently available disk drives on Windows.
 
static const char * logicalDriveStrings ()
 Returns a buffer with strings that specify valid drives in the system on Windows.
 
static nctl::String executableDir ()
 Returns the path of the directory where the executable resides.
 
static nctl::String currentDir ()
 Returns the path of the current working directory.
 
static bool setCurrentDir (const char *path)
 Sets the current working directory, the starting point for interpreting relative paths.
 
static bool isDirectory (const char *path)
 Returns true if the specified path is a directory.
 
static bool isFile (const char *path)
 Returns true if the specified path is a file.
 
static bool exists (const char *path)
 Returns true if the file or directory exists.
 
static bool isReadable (const char *path)
 Returns true if the file or directory is readable.
 
static bool isWritable (const char *path)
 Returns true if the file or directory is writeable.
 
static bool isExecutable (const char *path)
 Returns true if the file or directory is executable.
 
static bool isReadableFile (const char *path)
 Returns true if the path is a file and is readable.
 
static bool isWritableFile (const char *path)
 Returns true if the path is a file and is writeable.
 
static bool isHidden (const char *path)
 Returns true if the file or directory is hidden.
 
static bool setHidden (const char *path, bool hidden)
 Makes a file or a directory hidden or not.
 
static bool createDir (const char *path)
 Creates a new directory.
 
static bool deleteEmptyDir (const char *path)
 Deletes an empty directory.
 
static bool deleteFile (const char *path)
 Deletes a file.
 
static bool rename (const char *oldPath, const char *newPath)
 Renames or moves a file or a directory.
 
static bool copy (const char *oldPath, const char *newPath)
 Copies a file.
 
static long int fileSize (const char *path)
 Returns the file size in bytes.
 
static FileDate lastModificationTime (const char *path)
 Returns the last time the file or directory was modified.
 
static FileDate lastAccessTime (const char *path)
 Returns the last time the file or directory was accessed.
 
static int permissions (const char *path)
 Returns the file or directory permissions in a mask.
 
static bool changePermissions (const char *path, int mode)
 Sets the file or directory permissions to those of the mask.
 
static bool addPermissions (const char *path, int mode)
 Adds the permissions in the mask to a file or a directory.
 
static bool removePermissions (const char *path, int mode)
 Removes the permissions in the mask from a file or a directory.
 
static const nctl::StringdataPath ()
 Returns the base directory for data loading.
 
static const nctl::StringhomePath ()
 Returns the current user home directory.
 
static const nctl::StringsavePath ()
 Returns the writable directory for saving data.
 
static const nctl::StringcachePath ()
 Returns the writable directory for saving cache data.
 

Static Public Attributes

static const unsigned int MaxPathLength = PATH_MAX
 Maximum allowed length for a path string.
 

Friends

class AppConfiguration
 The AppConfiguration class needs to access dataPath_
 

Detailed Description

File system related methods.

Member Function Documentation

◆ absolutePath()

nctl::String ncine::FileSystem::absolutePath ( const char *  path)
static

Returns an absolute path from a relative one.

It also resolves dot references to current and parent directories, and double separators

◆ addPermissions()

bool ncine::FileSystem::addPermissions ( const char *  path,
int  mode 
)
static

Adds the permissions in the mask to a file or a directory.

Returns
True if the new permission mode was added

◆ changePermissions()

bool ncine::FileSystem::changePermissions ( const char *  path,
int  mode 
)
static

Sets the file or directory permissions to those of the mask.

Returns
True if the permission mode was changed

◆ copy()

bool ncine::FileSystem::copy ( const char *  oldPath,
const char *  newPath 
)
static

Copies a file.

Returns
True if the file has been copied

◆ createDir()

bool ncine::FileSystem::createDir ( const char *  path)
static

Creates a new directory.

Returns
True if the new directory has been created

◆ deleteEmptyDir()

bool ncine::FileSystem::deleteEmptyDir ( const char *  path)
static

Deletes an empty directory.

Returns
True if the empty directory has been deleted

◆ deleteFile()

bool ncine::FileSystem::deleteFile ( const char *  path)
static

Deletes a file.

Returns
True if the file has been deleted

◆ logicalDrives()

unsigned long ncine::FileSystem::logicalDrives ( )
static

Returns a bitmask representing the currently available disk drives on Windows.

/note The function only works on Windows, it returns 0 on other platforms

◆ logicalDriveStrings()

const char * ncine::FileSystem::logicalDriveStrings ( )
static

Returns a buffer with strings that specify valid drives in the system on Windows.

/note The function only works on Windows, it returns nullptr on other platforms

◆ removePermissions()

bool ncine::FileSystem::removePermissions ( const char *  path,
int  mode 
)
static

Removes the permissions in the mask from a file or a directory.

Returns
True if the permission mode was removed

◆ rename()

bool ncine::FileSystem::rename ( const char *  oldPath,
const char *  newPath 
)
static

Renames or moves a file or a directory.

Returns
True if the file or directory has been renamed or moved

◆ setCurrentDir()

bool ncine::FileSystem::setCurrentDir ( const char *  path)
static

Sets the current working directory, the starting point for interpreting relative paths.

Returns
True if the directory has been successfully changed

◆ setHidden()

bool ncine::FileSystem::setHidden ( const char *  path,
bool  hidden 
)
static

Makes a file or a directory hidden or not.

Returns
True if the new hidden state has been successfully set

The documentation for this class was generated from the following files: