Skip to content

Commit

Permalink
gral_directory_create
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelash committed Nov 20, 2023
1 parent 70424d3 commit c51accd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions gral.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ void *gral_file_map(struct gral_file *file, size_t size);
void gral_file_unmap(void *address, size_t size);
void gral_file_rename(char const *old_path, char const *new_path);
void gral_file_remove(char const *path);
void gral_directory_create(char const *path);
void gral_directory_iterate(char const *path, void (*callback)(char const *name, void *user_data), void *user_data);
void gral_directory_remove(char const *path);

Expand Down
4 changes: 4 additions & 0 deletions gral_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,10 @@ void gral_file_remove(char const *path) {
unlink(path);
}

void gral_directory_create(char const *path) {
mkdir(path, 0777);
}

void gral_directory_iterate(char const *path, void (*callback)(char const *name, void *user_data), void *user_data) {
DIR *directory = opendir(path);
struct dirent *entry;
Expand Down
4 changes: 4 additions & 0 deletions gral_macos.m
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,10 @@ void gral_file_remove(char const *path) {
unlink(path);
}

void gral_directory_create(char const *path) {
mkdir(path, 0777);
}

void gral_directory_iterate(char const *path, void (*callback)(char const *name, void *user_data), void *user_data) {
DIR *directory = opendir(path);
struct dirent *entry;
Expand Down
4 changes: 4 additions & 0 deletions gral_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,10 @@ void gral_file_remove(char const *path) {
DeleteFile(utf8_to_utf16(path));
}

void gral_directory_create(char const *path) {
CreateDirectory(utf8_to_utf16(path), NULL);
}

void gral_directory_iterate(char const *path_utf8, void (*callback)(char const *name, void *user_data), void *user_data) {
int length = MultiByteToWideChar(CP_UTF8, 0, path_utf8, -1, NULL, 0);
Buffer<wchar_t> path_utf16(length + 2);
Expand Down

0 comments on commit c51accd

Please sign in to comment.