sincerely Singaporean

If you have not done so, read this full tutorial on how to use SGEXTN to build an application.

SGXFileSystem

see header file

see source file

class SGXFileSystem;

part of SGEXTN module SG_FileSystem

provides access to the file system

detailed description

list of all including inherited members

implementation details

preprocessor file inclusion directive: #include ‹SGXFileSystem.h›

CMake target for BuildLah: SGEXTN::SG_FileSystem

see this link for more information about BuildLah

parent class: (none)

children classes: (none)

static member variables

static SGXString configFilePath;

static SGXString userDataFilePath;

static member functions

static int createFile(const SGXString& s);

static int createFolder(const SGXString& s);

static SGXString decodeFromFileName(const SGXString& s);

static int duplicateFile(const SGXString& startPath, const SGXString& endPath);

static int duplicateFolder(const SGXString& startPath, const SGXString& endPath);

static SGXString encodeToFileName(const SGXString& s);

static bool fileExists(const SGXString& s);

static bool folderExists(const SGXString& s);

static SGXTimeStamp getFileCreationTime(const SGXString& s);

static SGXString getFileExtension(const SGXString& s);

static SGXTimeStamp getFileLastEditTime(const SGXString& s);

static SGXString getFileName(const SGXString& s);

static SGXString getFileNameNoExtension(const SGXString& s);

static long long getFileSize(const SGXString& s);

static SGLArraySGXStringgetFilesList(const SGXString& s);

static SGLArraySGXStringgetFilesListContainingName(const SGXString& s, const SGXString& name);

static SGLArraySGXStringgetFilesListContainingNameRecursive(const SGXString& s, const SGXString& name);

static SGLArraySGXStringgetFilesListRecursive(const SGXString& s);

static SGLArraySGXStringgetFilesListWithExtension(const SGXString& s, const SGXString& ext);

static SGLArraySGXStringgetFilesListWithExtensionRecursive(const SGXString& s, const SGXString& ext);

static SGXTimeStamp getFolderCreationTime(const SGXString& s);

static SGXTimeStamp getFolderLastEditTime(const SGXString& s);

static SGXString getFolderName(const SGXString& s);

static long long getFolderSize(const SGXString& s);

static SGLArraySGXStringgetFoldersList(const SGXString& s);

static SGXString getFreePath(const SGXString& prefix, const SGXString& unencodedName, const SGXString& postfix);

static SGXString getParentName(const SGXString& s);

static SGXString getParentPath(const SGXString& s);

static SGXString joinFilePaths(const SGXString& a, const SGXString& b);

static int moveFile(const SGXString& startPath, const SGXString& endPath);

static int moveFolder(const SGXString& startPath, const SGXString& endPath);

static bool numberAwareLesserThan(const SGXString& s1, const SGXString& s2);

static bool numberAwareLesserThanBase16(const SGXString& s1, const SGXString& s2);

static void openLink(const SGXString& link);

static bool pathIsSubfolder(const SGXString& childPath, const SGXString& parentPath);

static int permanentDeleteFile(const SGXString& s);

static int permanentDeleteFolder(const SGXString& s);

Detailed Description

SGXFileSystem allows access to the file system. This includes iterating through files and folders, and querying for properties of files and folders. Use SGXFile instead to read and write files, and use SGXFileBinUtilities instead to manage the SGEXTN builtin file bin.

Implementation Details

Internally uses QDir, QFileInfo, and QFile

static SGXString configFilePath;

The folder that you should keep application settings files in.

Setting this manually is undefined behaviour.

static SGXString userDataFilePath;

The folder that you should keep user data in.

Setting this manually is undefined behaviour.

static int createFile(const SGXString& s);

Creates a file at s. This returns -2 if a file system error caused the operation to fail, 0 if the file already exists, and 1 if the operation was successful.

static int createFolder(const SGXString& s);

Creates a folder at s. This returns -2 if a file system error caused the operation to fail, 0 if the file already exists, and 1 if the operation was successful.

static SGXString decodeFromFileName(const SGXString& s);

Reverses SGXFileSystem::encodeToFileName for s.

If s is not a valid encoded file name, this will return s.

static int duplicateFile(const SGXString& startPath, const SGXString& endPath);

Copies the file at startPath to endPath. This returns -2 if a file system error caused the operation to fail, 0 if there is already a file at endPath or if there is no file at startPath, and 1 if the operation was successful.

static int duplicateFolder(const SGXString& startPath, const SGXString& endPath);

Copies the folder at startPath to endPath. This returns -2 if a file system error caused the operation to fail, 0 if there is already a folder at endPath or if there is no folder at startPath, and 1 if the operation was successful.

static SGXString encodeToFileName(const SGXString& s);

Encodes s to a file name, the SGEXTN provided encoding that is guaranteed to be safe on all file systems, including case insensitive ones. The file name is as readable as reasonably possible while allowing all Unicode characters.

Encoded file names always start with sg0

static bool fileExists(const SGXString& s);

Returns if any file exists at s.

static bool folderExists(const SGXString& s);

Returns if any folder exists at s.

static SGXTimeStamp getFileCreationTime(const SGXString& s);

Returns the time at which the file at s was created in the form of a SGXTimeStamp.

If there is no file at s or if file creation time is not supported by the file system, this returns SGXTimeStamp::zero.

static SGXString getFileExtension(const SGXString& s);

Returns the extension of the file at path s. This does not include the dot.

static SGXTimeStamp getFileLastEditTime(const SGXString& s);

Returns the time at which the file at s was last opened in a write capable mode.

If there is no file at s, this returns SGXTimeStamp::zero.

static SGXString getFileName(const SGXString& s);

Returns the name of the file at path s.

static SGXString getFileNameNoExtension(const SGXString& s);

Returns the file name of the file at path s with the extension removed.

static long long getFileSize(const SGXString& s);

Returns the size of the file at s in bytes.

If there is no file at s, this returns 0.

static SGLArraySGXStringgetFilesList(const SGXString& s);

Returns a list of files inside folder s by their paths.

If s does not exist, an empty list is returned.

static SGLArraySGXStringgetFilesListContainingName(const SGXString& s, const SGXString& name);

Returns a list of paths to files in folder s containing a substring of name in their names.

An empty list is returned if there is no folder at s.

static SGLArraySGXStringgetFilesListContainingNameRecursive(const SGXString& s, const SGXString& name);

Returns a list of paths to files in folder s including recursive subfolders containing a substring of name in their names.

An empty list is returned if there is no folder at s.

static SGLArraySGXStringgetFilesListRecursive(const SGXString& s);

Returns a list of files inside folder s and its recursive subfolders by their paths.

If s does not exist, an empty list is returned.

static SGLArraySGXStringgetFilesListWithExtension(const SGXString& s, const SGXString& ext);

Returns a list of paths to files in folder s with extension matching ext. ext should not include the dot.

An empty list is returned if there is no folder at s.

static SGLArraySGXStringgetFilesListWithExtensionRecursive(const SGXString& s, const SGXString& ext);

Returns a list of paths to files in folder s including recursive subfolders, with extension matching ext. ext should not include the dot.

An empty list is returned if there is no folder at s.

static SGXTimeStamp getFolderCreationTime(const SGXString& s);

Returns the time at which the folder at s was created in the form of a SGXTimeStamp.

If there is no folder at s or if folder creation time is not supported by the file system, this returns SGXTimeStamp::zero.

static SGXTimeStamp getFolderLastEditTime(const SGXString& s);

Returns the time at which the folder at s was last opened in a write capable mode.

If there is no folder at s, this returns SGXTimeStamp::zero.

static SGXString getFolderName(const SGXString& s);

Returns the name of the folder at path s.

static long long getFolderSize(const SGXString& s);

Returns the size of the folder at s, which is the sum of sizes of all its subfolders, in bytes.

If there is no folder at s, this returns 0.

static SGLArraySGXStringgetFoldersList(const SGXString& s);

Returns a list of subfolders inside folder s by their paths.

If s does not exist, an empty list is returned.

static SGXString getFreePath(const SGXString& prefix, const SGXString& unencodedName, const SGXString& postfix);

This should be used to replace directly setting the path as prefix/SGXFileSystem::encodeToFileName(unencodedName)postfix to avoid file name collisions causing accidental overwrite.

static SGXString getParentName(const SGXString& s);

Returns the name of the parent folder of s.

static SGXString getParentPath(const SGXString& s);

Returns the path to the parent folder of s.

static SGXString joinFilePaths(const SGXString& a, const SGXString& b);

Returns the file path a/b, this handles automatically trailing slash in a and leading slash in b if any are present.

If either a or b is an empty string, this will crash.

static int moveFile(const SGXString& startPath, const SGXString& endPath);

Moves the file at startPath to endPath. This returns -2 if a file system error caused the operation to fail, 0 if there is already a file at endPath or if there is no file at startPath, and 1 if the operation was successful.

static int moveFolder(const SGXString& startPath, const SGXString& endPath);

Moves the folder at startPath to endPath. This returns -2 if a file system error caused the operation to fail, 0 if there is already a folder at endPath or if there is no folder at startPath, and 1 if the operation was successful.

static bool numberAwareLesserThan(const SGXString& s1, const SGXString& s2);

Comparator used by SGXNumberAwareFilePathLesserThan and SGXNumberAwareFilePathMoreThan, returns if a file with name s1 should be displayed in front of a file with name s2 when number aware lesser than sorting is used.

The file names are decoded before comparison.

static bool numberAwareLesserThanBase16(const SGXString& s1, const SGXString& s2);

Comparator used by SGXNumberAwareFilePathLesserThanBase16 and SGXNumberAwareFilePathMoreThanBase16, returns if a file with name s1 should be displayed in front of a file with name s2 when base16 number aware lesser than sorting is used.

The file names are decoded before comparison.

Opens the website link link in the system default browser.

There is no need to put the https:// in front of the link, just the website link itself is sufficient.

If the link is invalid or does not exist, the user's browser will see the error, this will not affect the application.

static bool pathIsSubfolder(const SGXString& childPath, const SGXString& parentPath);

Returns if childPath is a possibly recursive subfolder of parentPath.

static int permanentDeleteFile(const SGXString& s);

Permanently deletes the file at s. This returns -2 if a file system error caused the operation to fail, 0 if there is no file at s, and 1 if the operation was successful.

This can cause irreversible loss of user data if used on user files. Use this only on application generated settings files. For deleting user files, use SGXFileBinUtilities::deleteFile instead to allow recovery.

static int permanentDeleteFolder(const SGXString& s);

Permanently deletes the folder at s. This returns -2 if a file system error caused the operation to fail, 0 if there is no folder at s, and 1 if the operation was successful.

This can cause irreversible loss of user data if used on user files. Use this only on application generated settings files. For deleting user files, use SGXFileBinUtilities::deleteFolder instead to allow recovery.

©2025 05524F.sg (Singapore)

contact 05524F / report a bug / make a suggestion

about 05524F SINGAPORE values

list of 05524F projects