Skip to content

Commit 9314050

Browse files
authored
Revert "IO: optimize createSubfolders (#1382)"
This reverts commit 0284e4c.
1 parent 0a61031 commit 9314050

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/common/io/io_unix.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323

2424
static void createSubfolders(const char* fileName)
2525
{
26-
char path[PATH_MAX];
26+
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
27+
2728
char *token = NULL;
28-
char *pathTail = path;
2929
while((token = strchr(fileName, '/')) != NULL)
3030
{
31-
uint32_t length = (uint32_t)(token - fileName + 1);
32-
pathTail = ffStrCopyN(pathTail, fileName, length);
33-
mkdir(path, S_IRWXU | S_IRGRP | S_IROTH);
31+
ffStrbufAppendNS(&path, (uint32_t)(token - fileName + 1), fileName);
32+
mkdir(path.chars, S_IRWXU | S_IRGRP | S_IROTH);
3433
fileName = token + 1;
3534
}
3635
}

src/common/io/io_windows.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88

99
static void createSubfolders(const char* fileName)
1010
{
11-
char path[MAX_PATH];
11+
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreate();
1212
char *token = NULL;
13-
char *pathTail = path;
1413
while((token = strchr(fileName, '/')) != NULL)
1514
{
16-
uint32_t length = (uint32_t)(token - fileName + 1);
17-
pathTail = ffStrCopyN(pathTail, fileName, length);
18-
CreateDirectoryA(path, NULL);
15+
ffStrbufAppendNS(&path, (uint32_t)(token - fileName + 1), fileName);
16+
CreateDirectoryA(path.chars, NULL);
1917
fileName = token + 1;
2018
}
2119
}

0 commit comments

Comments
 (0)