const std = @import("std"); pub const c = @import("c.zig").c; pub const Time = i64; pub inline fn getBasePath() [*c]const u8 { return c.SDL_GetBasePath(); } pub inline fn getPrefPath(org: [*c]const u8, app: [*c]const u8) [*c]u8 { return c.SDL_GetPrefPath(org, app); } pub const Folder = enum(c_int) { folderHome, //The folder which contains all of the current user's data, preferences, and documents. It usually contains most of the other folders. If a requested folder does not exist, the home folder can be considered a safe fallback to store a user's documents. folderDesktop, //The folder of files that are displayed on the desktop. Note that the existence of a desktop folder does not guarantee that the system does show icons on its desktop; certain GNU/Linux distros with a graphical environment may not have desktop icons. folderDocuments, //User document files, possibly application-specific. This is a good place to save a user's projects. folderDownloads, //Standard folder for user files downloaded from the internet. folderMusic, //Music files that can be played using a standard music player (mp3, ogg...). folderPictures, //Image files that can be displayed using a standard viewer (png, jpg...). folderPublicshare, //Files that are meant to be shared with other users on the same computer. folderSavedgames, //Save files for games. folderScreenshots, //Application screenshots. folderTemplates, //Template files to be used when the user requests the desktop environment to create a new file in a certain folder, such as "New Text File.txt". Any file in the Templates folder can be used as a starting point for a new file. folderVideos, //Video files that can be played using a standard video player (mp4, webm...). folderCount, }; pub inline fn getUserFolder(folder: Folder) [*c]const u8 { return c.SDL_GetUserFolder(folder); } pub const PathType = enum(c_int) { pathtypeNone, //path does not exist pathtypeFile, //a normal file pathtypeDirectory, //a directory pathtypeOther, }; pub const PathInfo = extern struct { _type: PathType, // the path type size: u64, // the file size in bytes create_time: Time, // the time when the path was created modify_time: Time, // the last time the path was modified access_time: Time, // the last time the path was read }; pub const GlobFlags = packed struct(u32) { globCaseinsensitive: bool = false, pad0: u30 = 0, rsvd: bool = false, }; pub inline fn createDirectory(path: [*c]const u8) bool { return @bitCast(c.SDL_CreateDirectory(path)); } pub const EnumerationResult = enum(c_int) { enumContinue, //Value that requests that enumeration continue. enumSuccess, //Value that requests that enumeration stop, successfully. enumFailure, }; pub const EnumerateDirectoryCallback = c.SDL_EnumerateDirectoryCallback; pub inline fn enumerateDirectory(path: [*c]const u8, callback: EnumerateDirectoryCallback, userdata: ?*anyopaque) bool { return @bitCast(c.SDL_EnumerateDirectory(path, callback, userdata)); } pub inline fn removePath(path: [*c]const u8) bool { return @bitCast(c.SDL_RemovePath(path)); } pub inline fn renamePath(oldpath: [*c]const u8, newpath: [*c]const u8) bool { return @bitCast(c.SDL_RenamePath(oldpath, newpath)); } pub inline fn copyFile(oldpath: [*c]const u8, newpath: [*c]const u8) bool { return @bitCast(c.SDL_CopyFile(oldpath, newpath)); } pub inline fn getPathInfo(path: [*c]const u8, info: ?*PathInfo) bool { return @bitCast(c.SDL_GetPathInfo(path, info)); } pub inline fn globDirectory(path: [*c]const u8, pattern: [*c]const u8, flags: GlobFlags, count: *c_int) [*c][*c]u8 { return c.SDL_GlobDirectory(path, pattern, @bitCast(flags), @ptrCast(count)); }