diff --git a/ppremake/dSearchPath.I b/ppremake/dSearchPath.I index a5735fd0f8..9f97764a4c 100644 --- a/ppremake/dSearchPath.I +++ b/ppremake/dSearchPath.I @@ -4,15 +4,15 @@ //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved // // All use of this software is subject to the terms of the Panda 3d // Software license. You should have received a copy of this license // along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . +// the license at http://etc.cmu.edu/panda3d/docs/license/ . // // To contact the maintainers of this program write to -// panda3d@yahoogroups.com . +// panda3d-general@lists.sourceforge.net . // //////////////////////////////////////////////////////////////////// diff --git a/ppremake/dSearchPath.cxx b/ppremake/dSearchPath.cxx index 9d67557e7d..9fb7555827 100644 --- a/ppremake/dSearchPath.cxx +++ b/ppremake/dSearchPath.cxx @@ -4,15 +4,15 @@ //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved // // All use of this software is subject to the terms of the Panda 3d // Software license. You should have received a copy of this license // along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . +// the license at http://etc.cmu.edu/panda3d/docs/license/ . // // To contact the maintainers of this program write to -// panda3d@yahoogroups.com . +// panda3d-general@lists.sourceforge.net . // //////////////////////////////////////////////////////////////////// diff --git a/ppremake/dSearchPath.h b/ppremake/dSearchPath.h index 34c27adced..9c0f19a1c9 100644 --- a/ppremake/dSearchPath.h +++ b/ppremake/dSearchPath.h @@ -4,15 +4,15 @@ //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved // // All use of this software is subject to the terms of the Panda 3d // Software license. You should have received a copy of this license // along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . +// the license at http://etc.cmu.edu/panda3d/docs/license/ . // // To contact the maintainers of this program write to -// panda3d@yahoogroups.com . +// panda3d-general@lists.sourceforge.net . // //////////////////////////////////////////////////////////////////// @@ -24,8 +24,6 @@ #include "filename.h" #include -#define pvector std::vector - /////////////////////////////////////////////////////////////////// // Class : DSearchPath // Description : This class stores a list of directories that can be @@ -52,7 +50,7 @@ public: void add_file(const Filename &file); private: - typedef pvector Files; + typedef vector Files; Files _files; }; @@ -86,7 +84,7 @@ PUBLISHED: void write(ostream &out, int indent_level = 0) const; private: - typedef pvector Directories; + typedef vector Directories; Directories _directories; }; diff --git a/ppremake/filename.I b/ppremake/filename.I index e0c01bc439..1ab5ecb8fe 100644 --- a/ppremake/filename.I +++ b/ppremake/filename.I @@ -4,15 +4,15 @@ //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved // // All use of this software is subject to the terms of the Panda 3d // Software license. You should have received a copy of this license // along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . +// the license at http://etc.cmu.edu/panda3d/docs/license/ . // // To contact the maintainers of this program write to -// panda3d@yahoogroups.com . +// panda3d-general@lists.sourceforge.net . // //////////////////////////////////////////////////////////////////// diff --git a/ppremake/filename.cxx b/ppremake/filename.cxx index 2b49e1248a..31c1d38ec6 100644 --- a/ppremake/filename.cxx +++ b/ppremake/filename.cxx @@ -4,15 +4,15 @@ //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved // // All use of this software is subject to the terms of the Panda 3d // Software license. You should have received a copy of this license // along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . +// the license at http://etc.cmu.edu/panda3d/docs/license/ . // // To contact the maintainers of this program write to -// panda3d@yahoogroups.com . +// panda3d-general@lists.sourceforge.net . // //////////////////////////////////////////////////////////////////// @@ -1160,8 +1160,8 @@ find_on_searchpath(const DSearchPath &searchpath) { bool Filename:: scan_directory(vector_string &contents) const { #if defined(WIN32_VC) - // Use FindFirstFile()/FindNextFile() to walk through the list of - // files in a directory. + // Use Windows' FindFirstFile() / FindNextFile() to walk through the + // list of files in a directory. size_t orig_size = contents.size(); string match; @@ -1194,38 +1194,9 @@ scan_directory(vector_string &contents) const { sort(contents.begin() + orig_size, contents.end()); return scan_ok; -#elif defined(HAVE_GLOB_H) - // In some cases, particularly with NFS, it seems that opendir() - // .. readdir() fails to properly read the entire directory ("Value - // too large for defined data type"), but glob() succeeds. - string dirname; - if (empty()) { - dirname = "*"; - } else if (_filename[_filename.length() - 1] == '/') { - dirname = _filename + "*"; - } else { - dirname = _filename + "/*"; - } - - glob_t globbuf; - - int r = glob(dirname.c_str(), GLOB_ERR, NULL, &globbuf); -#ifdef GLOB_NOMATCH - if (r != 0 && r != GLOB_NOMATCH) { - perror(dirname.c_str()); - return false; - } -#endif - size_t offset = dirname.size() - 1; - - for (int i = 0; globbuf.gl_pathv[i] != NULL; i++) { - contents.push_back(globbuf.gl_pathv[i] + offset); - } - globfree(&globbuf); - - return true; - #elif defined(HAVE_DIRENT_H) + // Use Posix's opendir() / readir() to walk through the list of + // files in a directory. size_t orig_size = contents.size(); string dirname; @@ -1248,16 +1219,66 @@ scan_directory(vector_string &contents) const { } d = readdir(root); } + + // It turns out to be a mistake to check the value of errno after + // calling readdir(), since it might have been set to non-zero + // during some internal operation of readdir(), even though there + // wasn't really a problem with scanning the directory itself. + /* if (errno != 0 && errno != ENOENT && errno != ENOTDIR) { cerr << "Error occurred while scanning directory " << dirname << "\n"; perror(dirname.c_str()); closedir(root); return false; } + */ closedir(root); sort(contents.begin() + orig_size, contents.end()); return true; + +#elif defined(HAVE_GLOB_H) + // It's hard to imagine a system that provides glob.h but does not + // provide openddir() .. readdir(), but this code is leftover from a + // time when there was an undetected bug in the above readdir() + // loop, and it works, so we might as well keep it around for now. + string dirname; + if (empty()) { + dirname = "*"; + } else if (_filename[_filename.length() - 1] == '/') { + dirname = _filename + "*"; + } else { + dirname = _filename + "/*"; /* comment to fix emacs syntax hilight */ + } + + glob_t globbuf; + + int r = glob(dirname.c_str(), GLOB_ERR, NULL, &globbuf); + + if (r != 0) { + // Some error processing the match string. If our version of + // glob.h defines GLOB_NOMATCH, then we can differentiate an empty + // return result from some other kind of error. +#ifdef GLOB_NOMATCH + if (r != GLOB_NOMATCH) { + perror(dirname.c_str()); + return false; + } +#endif + + // Otherwise, all errors mean the same thing: no matches, but + // otherwise no problem. + return true; + } + + size_t offset = dirname.size() - 1; + + for (int i = 0; globbuf.gl_pathv[i] != NULL; i++) { + contents.push_back(globbuf.gl_pathv[i] + offset); + } + globfree(&globbuf); + + return true; #else // Don't know how to scan directories! diff --git a/ppremake/filename.h b/ppremake/filename.h index a62f7dbbcb..41dceaabe8 100644 --- a/ppremake/filename.h +++ b/ppremake/filename.h @@ -4,22 +4,22 @@ //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved // // All use of this software is subject to the terms of the Panda 3d // Software license. You should have received a copy of this license // along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . +// the license at http://etc.cmu.edu/panda3d/docs/license/ . // // To contact the maintainers of this program write to -// panda3d@yahoogroups.com . +// panda3d-general@lists.sourceforge.net . // //////////////////////////////////////////////////////////////////// #ifndef FILENAME_H #define FILENAME_H -#include "ppremake.h" +#include "dtoolbase.h" #include "vector_string.h"