summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2011-04-15 12:54:13 -0700
committerAndrei Karas <akaras@inbox.ru>2011-04-15 23:30:01 +0300
commitb026b5440f8077562d8059db9277504d17a71de9 (patch)
tree8b138e1413d021860f0564617208512a9568416b /src/utils
parentab2633a52791309a0334b5282c960eb8dc5f3f5b (diff)
downloadplus-b026b5440f8077562d8059db9277504d17a71de9.tar.gz
plus-b026b5440f8077562d8059db9277504d17a71de9.tar.bz2
plus-b026b5440f8077562d8059db9277504d17a71de9.tar.xz
plus-b026b5440f8077562d8059db9277504d17a71de9.zip
Fix mkdir_r to not assume existence of PATH_MAX
Required to build on HURD, but good practice anyway. Reviewed-by: Thorbjørn Lindeijer
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mkdir.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp
index e71bd4892..18d526d47 100644
--- a/src/utils/mkdir.cpp
+++ b/src/utils/mkdir.cpp
@@ -37,18 +37,14 @@
#include "mkdir.h"
+/// Create a directory, making leading components first if necessary
int mkdir_r(const char *pathname)
{
- char tmp[PATH_MAX];
+ size_t len = static_cast<int>(strlen(pathname));
+ char tmp[len+2];
char *p;
- if (strlen(pathname) >= PATH_MAX - 2)
- return -1;
-
- strncpy(tmp, pathname, sizeof(tmp) - 1);
- tmp[PATH_MAX - 1] = '\0';
-
- int len = static_cast<int>(strlen(tmp));
+ strcpy(tmp, pathname);
// terminate the pathname with '/'
if (tmp[len - 1] != '/')