File 08_fix_dirlisting.patch of Package warmux
Description: Do not rely on dirent.d_type when calling readdir as this breaks on certain filesystems.
Origin: upstream, http://svn.gna.org/viewcvs/warmux?view=revision&revision=10374
Bug: http://gna.org/bugs/?20593
Bug-Debian: http://bugs.debian.org/701214
--- a/lib/warmux/tools/file_tools.cpp
+++ b/lib/warmux/tools/file_tools.cpp
@@ -33,6 +33,8 @@
# include <direct.h>
# undef DeleteFile // windows.h defines it I think
#else
+# include <sys/types.h>
+# include <sys/stat.h>
# include <stdlib.h> // getenv
# include <unistd.h> // not needed by mingw
#endif
@@ -275,18 +277,14 @@
{
DIR *dir;
struct dirent *file;
-#ifdef __SYMBIAN32__
std::string dname;
-#endif
};
FolderSearch* OpenFolder(const std::string& dirname)
{
FolderSearch *f = new FolderSearch;
f->dir = opendir(dirname.c_str());
-#ifdef __SYMBIAN32__
f->dname = dirname;
-#endif
if (!f->dir) {
delete f;
@@ -300,11 +298,11 @@
{
while ((f->file = readdir(f->dir)) != NULL) {
+ if (
#ifdef __SYMBIAN32__
- if (f->file->d_namlen && DoesFolderExist(f->dname+"/"+std::string(f->file->d_name))) {
-#else
- if (f->file->d_type == DT_DIR) {
+ f->file->d_namlen &&
#endif
+ DoesFolderExist(f->dname+"/"+std::string(f->file->d_name))) {
// If we are also looking for files, report it isn't one
if (file)
file = false;
@@ -316,11 +314,11 @@
continue;
// This is a file and we do search for file
+ if (
#ifdef __SYMBIAN32__
- if (f->file->d_namlen && DoesFileExist(f->dname+"/"+std::string(f->file->d_name))) {
-#else
- if (f->file->d_type == DT_REG) {
+ f->file->d_namlen &&
#endif
+ DoesFileExist(f->dname+"/"+std::string(f->file->d_name))) {
file = true;
return f->file->d_name;
}