From b3e19c24d384465b38eec44ee19e4cff0a932939 Mon Sep 17 00:00:00 2001 From: Raphael Geissert Date: Sat, 12 Feb 2011 15:40:30 -0600 Subject: [PATCH] Fix build when PATH_MAX is not defined POSIX says it _may_ be defined. Alternative implementation follows POSIX.1-2008. --- cli/filelister_unix.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/filelister_unix.cpp b/cli/filelister_unix.cpp index f9263eb78..e961f9a84 100644 --- a/cli/filelister_unix.cpp +++ b/cli/filelister_unix.cpp @@ -60,8 +60,13 @@ void FileListerUnix::recursiveAddFiles2(std::vector &relative, if (filename[filename.length()-1] != '/') { // File +#ifdef PATH_MAX char fname[PATH_MAX]; if (realpath(filename.c_str(), fname) == NULL) +#else + char *fname; + if ((fname = realpath(filename.c_str(), NULL)) == NULL) +#endif { continue; } @@ -69,6 +74,9 @@ void FileListerUnix::recursiveAddFiles2(std::vector &relative, // Does absolute path exist? then bail out if (std::find(absolute.begin(), absolute.end(), std::string(fname)) != absolute.end()) { +#ifndef PATH_MAX + free(fname); +#endif continue; } @@ -77,6 +85,10 @@ void FileListerUnix::recursiveAddFiles2(std::vector &relative, relative.push_back(filename); absolute.push_back(fname); } + +#ifndef PATH_MAX + free(fname); +#endif } else {