diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2011-04-15 12:54:13 -0700 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2011-04-15 22:14:37 +0200 |
commit | 3c83cbf8055d4f13d21723f95c7c325fae8eae7a (patch) | |
tree | 0a91ce9309c5d430c1eecb7c46f0db305f8c708d /src | |
parent | 88b8acf8ad7a63d3a1d278e5c54208aa8c71f249 (diff) | |
download | mana-3c83cbf8055d4f13d21723f95c7c325fae8eae7a.tar.gz mana-3c83cbf8055d4f13d21723f95c7c325fae8eae7a.tar.bz2 mana-3c83cbf8055d4f13d21723f95c7c325fae8eae7a.tar.xz mana-3c83cbf8055d4f13d21723f95c7c325fae8eae7a.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')
-rw-r--r-- | src/utils/mkdir.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/utils/mkdir.cpp b/src/utils/mkdir.cpp index 43f5264e..bd9fd2b1 100644 --- a/src/utils/mkdir.cpp +++ b/src/utils/mkdir.cpp @@ -36,17 +36,13 @@ #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 = 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=strlen(tmp); + strcpy(tmp, pathname); // terminate the pathname with '/' if (tmp[len-1] != '/') { |