Berserk
|
Target platform file system access and file utils. More...
#include <FileSystem.hpp>
Classes | |
struct | Entry |
Directory entry. More... | |
Public Types | |
enum class | EntryType { File , Directory , Link , Unknown } |
Type of directory entry. More... | |
Public Member Functions | |
BRK_API | FileSystem () |
BRK_API | ~FileSystem ()=default |
BRK_API std::FILE * | OpenFile (const String &filepath, const String &mode) |
Open file by file path and mode. More... | |
BRK_API void | CloseFile (std::FILE *file) |
Close opened file. More... | |
BRK_API Ref< Data > | ReadFile (const String &filepath) |
Read file by file path. More... | |
BRK_API void | AddSearchPath (String path) |
Add search path. More... | |
BRK_API void | SetSearchPaths (std::vector< String > searchPaths) |
Set search paths for paths resolution. More... | |
BRK_API String | GetFullFilePath (const String &filename) |
Get full path for specified file. More... | |
BRK_API String | GetFullDirPath (const String &dirname) |
Get full path for specified directory. More... | |
BRK_API String | GetFileExtension (const String &filename) |
Retrieve file extension. More... | |
BRK_API String | GetFileName (const String &filename, bool withoutExtension=false) |
Get file name from file path. More... | |
BRK_API bool | IsAbsolutePath (const String &filename) |
Check is passed path is absolute. More... | |
BRK_API bool | IsFileExists (const String &filename) |
Check if specified file exists. More... | |
BRK_API bool | IsDirExists (const String &dirname) |
Check if specified directory exists. More... | |
BRK_API std::vector< Entry > | ListDir (const String &dir) |
List entries of the specified directory. More... | |
BRK_API const String & | GetExecutablePath () |
Path to the executable file of the application. More... | |
BRK_API String | GetExecutableDir () const |
Path to the executable directory where file of the application is located. More... | |
Target platform file system access and file utils.
|
strong |
Type of directory entry.
Enumerator | |
---|---|
File | Simple file |
Directory | Directory |
Link | Link or hyper-link for a file/directory |
Unknown | Entry has unknown type |
BRK_NS_BEGIN FileSystem::FileSystem | ( | ) |
InitCore file system
|
default |
void FileSystem::AddSearchPath | ( | String | path | ) |
Add search path.
Adds search path used to search engine files. New path is added as last path in the list of search paths (with lower priority). Adding new path invalidates previously cached path lookups.
path | Search path to add; must be not empty |
void FileSystem::CloseFile | ( | std::FILE * | file | ) |
Close opened file.
file | File handle to close |
String FileSystem::GetExecutableDir | ( | ) | const |
Path to the executable directory where file of the application is located.
const String & FileSystem::GetExecutablePath | ( | ) |
Path to the executable file of the application.
Retrieve file extension.
filename | File name to get extension |
Get file name from file path.
Get file name from relative or absolute path to the file. This function preserves file extension.
filename | Relative or absolute path |
withoutExtension | Pass true to remove extension |
Get full path for specified directory.
Attempts to resolve passed relative directory path using configured search paths of the file system class.
Uses cache of resolved entries to speed-up look ups.
dirname | Relative or absolute path |
Get full path for specified file.
Attempts to resolve passed relative file path using configured search paths of the file system class.
Uses cache of resolved entries to speed-up look ups.
filename | Relative or absolute path |
bool FileSystem::IsAbsolutePath | ( | const String & | filename | ) |
Check is passed path is absolute.
filename | Path to check |
bool FileSystem::IsDirExists | ( | const String & | dirname | ) |
Check if specified directory exists.
dirname | Relative or absolute path of the directory |
bool FileSystem::IsFileExists | ( | const String & | filename | ) |
Check if specified file exists.
filename | Relative or absolute path of the file |
std::vector< FileSystem::Entry > FileSystem::ListDir | ( | const String & | dir | ) |
List entries of the specified directory.
dir | Relative or absolute path of the directory |
Open file by file path and mode.
Opens file using provided full absolute file path. Automatically converts string path to required encoding of platform.
filepath | Absolute (full) path to file |
mode | Mode to open file |
Read file by file path.
Attempts to open and read content of the file, specified by file path. File content is read into allocated data container. If fails to open or read file, returns null.
filepath | Absolute (full) path to file |
void FileSystem::SetSearchPaths | ( | std::vector< String > | searchPaths | ) |
Set search paths for paths resolution.
Uses passed search paths to resolve relative file and directory paths to full paths.
searchPaths | List of search paths |