1#ifndef SDL3PP_FILESYSTEM_H_
2#define SDL3PP_FILESYSTEM_H_
4#include <SDL3/SDL_filesystem.h>
5#include "SDL3pp_stdinc.h"
190 return Path{SDL_GetPrefPath(org, app)};
261 SDL_FOLDER_SAVEDGAMES;
264 SDL_FOLDER_SCREENSHOTS;
306 return SDL_GetUserFolder(folder);
359 constexpr bool operator==(std::nullptr_t _)
const {
return !bool(*
this); }
380 SDL_GLOB_CASEINSENSITIVE;
495 CheckError(SDL_EnumerateDirectory(path, callback, userdata));
521 [](
void* userdata,
const char* dirname,
const char* fname) {
523 return cb(dirname, fname);
540 r.emplace_back(fname);
675 auto data =
CheckError(SDL_GlobDirectory(path, pattern, flags, &count));
Base class for SDL memory allocated array wrap.
Definition: SDL3pp_ownPtr.h:44
constexpr bool empty() const
True if size() == 0.
Definition: SDL3pp_ownPtr.h:74
char & back()
Return last element.
Definition: SDL3pp_ownPtr.h:149
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:198
Path GetPrefPath(StringParam org, StringParam app)
Get the user-and-app-specific path where files can be written.
Definition: SDL3pp_filesystem.h:188
constexpr Folder FOLDER_SCREENSHOTS
Application screenshots.
Definition: SDL3pp_filesystem.h:263
constexpr Folder FOLDER_DOCUMENTS
User document files, possibly application-specific.
Definition: SDL3pp_filesystem.h:244
std::function< EnumerationResult(const char *dirname, const char *fname)> EnumerateDirectoryCB
Callback for directory enumeration.
Definition: SDL3pp_filesystem.h:469
constexpr EnumerationResult ENUM_CONTINUE
Value that requests that enumeration continue.
Definition: SDL3pp_filesystem.h:409
SDL_PathType PathType
Types of filesystem entries.
Definition: SDL3pp_filesystem.h:320
constexpr Folder FOLDER_TEMPLATES
Template files to be used when the user requests the desktop environment to create a new file in a ce...
Definition: SDL3pp_filesystem.h:271
PathInfo GetPathInfo(StringParam path)
Get information about a filesystem path.
Definition: SDL3pp_filesystem.h:635
constexpr PathType PATHTYPE_OTHER
something completely different like a device node (not a symlink, those are always followed)
Definition: SDL3pp_filesystem.h:332
void RenamePath(StringParam oldpath, StringParam newpath)
Rename a file or directory.
Definition: SDL3pp_filesystem.h:579
constexpr GlobFlags GLOB_CASEINSENSITIVE
CASEINSENSITIVE.
Definition: SDL3pp_filesystem.h:379
constexpr Folder FOLDER_COUNT
Total number of types in this enum, not a folder type by itself.
Definition: SDL3pp_filesystem.h:279
SDL_EnumerationResult EnumerationResult
Possible results from an enumeration callback.
Definition: SDL3pp_filesystem.h:407
SDL_PathInfo PathInfoRaw
Alias to raw representation for PathInfo.
Definition: SDL3pp_filesystem.h:34
constexpr PathType PATHTYPE_NONE
path does not exist
Definition: SDL3pp_filesystem.h:322
constexpr EnumerationResult ENUM_FAILURE
Value that requests that enumeration stop, as a failure.
Definition: SDL3pp_filesystem.h:416
constexpr Folder FOLDER_PUBLICSHARE
Files that are meant to be shared with other users on the same computer.
Definition: SDL3pp_filesystem.h:258
constexpr EnumerationResult ENUM_SUCCESS
Value that requests that enumeration stop, successfully.
Definition: SDL3pp_filesystem.h:413
constexpr Folder FOLDER_SAVEDGAMES
Save files for games.
Definition: SDL3pp_filesystem.h:260
void EnumerateDirectory(StringParam path, EnumerateDirectoryCallback callback, void *userdata)
Enumerate a directory through a callback function.
Definition: SDL3pp_filesystem.h:491
Path GetCurrentDirectory()
Get what the system believes is the "current working directory.".
Definition: SDL3pp_filesystem.h:698
const char * GetUserFolder(Folder folder)
Finds the most suitable user folder for a specific purpose.
Definition: SDL3pp_filesystem.h:304
SDL_EnumerateDirectoryCallback EnumerateDirectoryCallback
Callback for directory enumeration.
Definition: SDL3pp_filesystem.h:442
constexpr Folder FOLDER_DOWNLOADS
Standard folder for user files downloaded from the internet.
Definition: SDL3pp_filesystem.h:247
constexpr Folder FOLDER_VIDEOS
Video files that can be played using a standard video player (mp4, webm...).
Definition: SDL3pp_filesystem.h:276
SDL_Folder Folder
The type of the OS-provided default folder for a specific purpose.
Definition: SDL3pp_filesystem.h:222
void CopyFile(StringParam oldpath, StringParam newpath)
Copy a file.
Definition: SDL3pp_filesystem.h:621
Uint32 GlobFlags
Flags for path matching.
Definition: SDL3pp_filesystem.h:377
void CreateDirectory(StringParam path)
Create a directory, and any missing parent directories.
Definition: SDL3pp_filesystem.h:395
constexpr Folder FOLDER_PICTURES
Image files that can be displayed using a standard viewer (png, jpg...).
Definition: SDL3pp_filesystem.h:255
void RemovePath(StringParam path)
Remove a file or an empty directory.
Definition: SDL3pp_filesystem.h:557
constexpr Folder FOLDER_DESKTOP
The folder of files that are displayed on the desktop.
Definition: SDL3pp_filesystem.h:238
constexpr Folder FOLDER_HOME
The folder which contains all of the current user's data, preferences, and documents.
Definition: SDL3pp_filesystem.h:230
const char * GetBasePath()
Get the directory where the application was run from.
Definition: SDL3pp_filesystem.h:133
constexpr PathType PATHTYPE_FILE
a normal file
Definition: SDL3pp_filesystem.h:324
constexpr PathType PATHTYPE_DIRECTORY
a directory
Definition: SDL3pp_filesystem.h:326
OwnArray< char * > GlobDirectory(StringParam path, StringParam pattern, GlobFlags flags=0)
Enumerate a directory tree, filtered by pattern, and return a list.
Definition: SDL3pp_filesystem.h:670
constexpr Folder FOLDER_MUSIC
Music files that can be played using a standard music player (mp3, ogg...).
Definition: SDL3pp_filesystem.h:252
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:310
Main include header for the SDL3pp library.
Information about a path on the filesystem.
Definition: SDL3pp_filesystem.h:343
constexpr bool operator==(std::nullptr_t _) const
Compare with nullptr.
Definition: SDL3pp_filesystem.h:359
constexpr PathInfo(const PathInfoRaw &pathInfo={})
Wraps PathInfo.
Definition: SDL3pp_filesystem.h:349
Convenience representation of a path under SDL.
Definition: SDL3pp_filesystem.h:44
Path & operator+=(std::string_view other)
Append.
Definition: SDL3pp_filesystem.h:49
Path operator+(std::string_view other) const
Append.
Definition: SDL3pp_filesystem.h:63
Path & operator+=(char ch)
Append.
Definition: SDL3pp_filesystem.h:56
Path & operator/=(std::string_view other)
Append path component.
Definition: SDL3pp_filesystem.h:79
Path operator/(std::string_view other) const
Append path component.
Definition: SDL3pp_filesystem.h:86
Path operator+(char ch) const
Append.
Definition: SDL3pp_filesystem.h:71
A simple std::string-like interface for SDL allocated strings.
Definition: SDL3pp_strings.h:153
StringResult & operator+=(std::string_view other)
Append string.
Definition: SDL3pp_strings.h:187
StringResult(const StringResult &other)
Copy ctor.
Definition: SDL3pp_strings.h:159