From 14cdab7e397b1f4b132b0d7fb1d961a6b74a1a71 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 1 Jun 2009 06:43:32 +0000 Subject: [PATCH] - Applied patch for fixing directory reading on Linux. SVN r1628 (trunk) --- src/resourcefiles/file_directory.cpp | 7 +++++-- src/resourcefiles/resourcefile.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/resourcefiles/file_directory.cpp b/src/resourcefiles/file_directory.cpp index f2bf77ae3..cb250ed1e 100644 --- a/src/resourcefiles/file_directory.cpp +++ b/src/resourcefiles/file_directory.cpp @@ -208,7 +208,9 @@ int FDirectory::AddDirectory(const char *dirpath) int FDirectory::AddDirectory(const char *dirpath) { - char *argv [2] = {dirpath, NULL }; + char *argv [2] = {NULL, NULL }; + argv[0] = new char[strlen(dirpath)+1]; + strcpy(argv[0], dirpath); FTS *fts; FTSENT *ent; int count = 0; @@ -216,7 +218,7 @@ int FDirectory::AddDirectory(const char *dirpath) fts = fts_open(argv, FTS_LOGICAL, NULL); if (fts == NULL) { - Printf "Failed to start directory traversal: %s\n", strerror(errno)); + Printf("Failed to start directory traversal: %s\n", strerror(errno)); return NULL; } while ((ent = fts_read(fts)) != NULL) @@ -240,6 +242,7 @@ int FDirectory::AddDirectory(const char *dirpath) count++; } fts_close(fts); + delete[] argv[0]; return count; } #endif diff --git a/src/resourcefiles/resourcefile.h b/src/resourcefiles/resourcefile.h index 03a0be4d8..bc07426e9 100644 --- a/src/resourcefiles/resourcefile.h +++ b/src/resourcefiles/resourcefile.h @@ -61,7 +61,7 @@ private: public: static FResourceFile *OpenResourceFile(const char *filename, FileReader *file, bool quiet = false); - static FResourceFile *FResourceFile::OpenDirectory(const char *filename); + static FResourceFile *OpenDirectory(const char *filename); virtual ~FResourceFile(); FileReader *GetReader() const { return Reader; } DWORD LumpCount() const { return NumLumps; }