Skip to content

SDL_filesystem feature request, SDL_CreateDirectory #4989

@ITotalJustice

Description

@ITotalJustice

Looking at the current filesystem files, seems that for a few platforms, we already have mkdir-like options

vita:

sceIoMkdir(retval, 0777);

emscripten:

if (mkdir(retval, 0700) != 0 && errno != EEXIST) {

haiku:

create_directory(retval, 0700); // Haiku api: creates missing dirs

os2:

DosCreateDir(acBuf, NULL);

cocoa:

mkdir(retval, 0700);

windows:

api_result = CreateDirectoryW(path, NULL);

riscos:

error = createDirectoryRecursive(dir);

winrt:

api_result = CreateDirectoryW(path, NULL);

unix:

if (mkdir(retval, 0700) != 0 && errno != EEXIST) {

here's an example of how the api could look

typedef enum
{
    SDL_DIRECTORY_READ = 1 << 0,
    SDL_DIRECTORY_WRITE = 1 << 1,
    SDL_DIRECTORY_EXECUTE = 1 << 2,

    SDL_DIRECTORY_RW = SDL_DIRECTORY_READ | SDL_DIRECTORY_WRITE,
    SDL_DIRECTORY_RWX = SDL_DIRECTORY_READ | SDL_DIRECTORY_WRITE | SDL_DIRECTORY_EXECUTE,
} SDL_DirectoryFlags;

int SDL_CreateDirectory(const char* path, Uint32 flags);

I'm not sure what the return code should look like. 0 on success probably, anything negative for error, maybe a positive value for warnings such as if the dir already exists?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions