From f3226e244bed7fce7ed2e4295dba90bd3395107c Mon Sep 17 00:00:00 2001 From: Elias Aebi Date: Mon, 20 Nov 2023 13:31:06 +0100 Subject: [PATCH] gral_directory_create --- gral.h | 3 ++- gral_linux.c | 6 +++++- gral_macos.m | 6 +++++- gral_windows.cpp | 6 +++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gral.h b/gral.h index 69b37d1..acc2b8f 100644 --- a/gral.h +++ b/gral.h @@ -1,6 +1,6 @@ /* -Copyright (c) 2016-2022 Elias Aebi +Copyright (c) 2016-2023 Elias Aebi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: @@ -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); diff --git a/gral_linux.c b/gral_linux.c index 31033b9..e5d9648 100644 --- a/gral_linux.c +++ b/gral_linux.c @@ -1,6 +1,6 @@ /* -Copyright (c) 2016-2022 Elias Aebi +Copyright (c) 2016-2023 Elias Aebi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: @@ -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; diff --git a/gral_macos.m b/gral_macos.m index 090c58e..47a8a8f 100644 --- a/gral_macos.m +++ b/gral_macos.m @@ -1,6 +1,6 @@ /* -Copyright (c) 2016-2022 Elias Aebi +Copyright (c) 2016-2023 Elias Aebi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: @@ -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; diff --git a/gral_windows.cpp b/gral_windows.cpp index edbf4ef..d5ea23d 100644 --- a/gral_windows.cpp +++ b/gral_windows.cpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2016-2022 Elias Aebi +Copyright (c) 2016-2023 Elias Aebi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: @@ -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 path_utf16(length + 2);