Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with mkdir on Windows #65

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.63])
AC_INIT([leech], [0.1.11], [https://github.com/larsewi/leech/issues], [leech],
AC_INIT([leech], [0.1.12], [https://github.com/larsewi/leech/issues], [leech],
[https://github.com/larsewi/leech])
AC_CONFIG_SRCDIR([lib/leech.h])

Expand Down
12 changes: 11 additions & 1 deletion lib/files.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include <sys/stat.h>
#include <unistd.h>

#ifdef _WIN32
#include <direct.h>
#endif // _WIN32

#include "definitions.h"
#include "logger.h"
#include "string_lib.h"
Expand Down Expand Up @@ -141,7 +145,13 @@ bool LCH_FileCreateParentDirectories(const char *const filename) {
const size_t num_dirs = LCH_ListLength(dirs);
for (size_t i = num_dirs; i > 0; i--) {
char *const dir = (char *)LCH_ListGet(dirs, i - 1);
if (mkdir(dir, (mode_t)0700) == -1) {
int ret =
#ifdef _WIN32
_mkdir(dir);
#else // _WIN32
mkdir(dir, (mode_t)0700);
#endif // _WIN32
if (ret == -1) {
LCH_LOG_ERROR("Failed to create parent directory '%s' for file '%s': %s",
dir, filename, strerror(errno));
LCH_ListDestroy(dirs);
Expand Down
Loading