diff --git a/gral.h b/gral.h index ae80632..69b37d1 100644 --- a/gral.h +++ b/gral.h @@ -177,7 +177,9 @@ size_t gral_file_get_size(struct gral_file *file); 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_iterate(char const *path, void (*callback)(char const *name, void *user_data), void *user_data); +void gral_directory_remove(char const *path); /*========= diff --git a/gral_linux.c b/gral_linux.c index 7e6288f..31033b9 100644 --- a/gral_linux.c +++ b/gral_linux.c @@ -747,6 +747,10 @@ void gral_file_rename(char const *old_path, char const *new_path) { rename(old_path, new_path); } +void gral_file_remove(char const *path) { + unlink(path); +} + 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; @@ -756,6 +760,10 @@ void gral_directory_iterate(char const *path, void (*callback)(char const *name, closedir(directory); } +void gral_directory_remove(char const *path) { + rmdir(path); +} + /*========= TIME diff --git a/gral_macos.m b/gral_macos.m index bab1b9b..090c58e 100644 --- a/gral_macos.m +++ b/gral_macos.m @@ -782,6 +782,10 @@ void gral_file_rename(char const *old_path, char const *new_path) { rename(old_path, new_path); } +void gral_file_remove(char const *path) { + unlink(path); +} + 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; @@ -791,6 +795,10 @@ void gral_directory_iterate(char const *path, void (*callback)(char const *name, closedir(directory); } +void gral_directory_remove(char const *path) { + rmdir(path); +} + /*========= TIME diff --git a/gral_windows.cpp b/gral_windows.cpp index 79711dc..edbf4ef 100644 --- a/gral_windows.cpp +++ b/gral_windows.cpp @@ -1146,6 +1146,10 @@ void gral_file_rename(char const *old_path, char const *new_path) { MoveFileEx(utf8_to_utf16(old_path), utf8_to_utf16(new_path), MOVEFILE_REPLACE_EXISTING); } +void gral_file_remove(char const *path) { + DeleteFile(utf8_to_utf16(path)); +} + 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 path_utf16(length + 2); @@ -1159,6 +1163,10 @@ void gral_directory_iterate(char const *path_utf8, void (*callback)(char const * FindClose(handle); } +void gral_directory_remove(char const *path) { + RemoveDirectory(utf8_to_utf16(path)); +} + /*========= TIME