Skip to content

Commit

Permalink
gral_directory_create
Browse files Browse the repository at this point in the history
  • Loading branch information
eyelash committed Dec 3, 2023
1 parent 70424d3 commit f3226e2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion gral.h
Original file line number Diff line number Diff line change
@@ -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:
Expand Down 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
6 changes: 5 additions & 1 deletion gral_linux.c
Original file line number Diff line number Diff line change
@@ -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:
Expand Down 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
6 changes: 5 additions & 1 deletion gral_macos.m
Original file line number Diff line number Diff line change
@@ -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:
Expand Down 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
6 changes: 5 additions & 1 deletion gral_windows.cpp
Original file line number Diff line number Diff line change
@@ -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:
Expand Down 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 f3226e2

Please sign in to comment.