netpanzer-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netPanzer-CVS] netpanzer/src/Lib/2D PackedSurface.cpp


From: Matthias Braun
Subject: [netPanzer-CVS] netpanzer/src/Lib/2D PackedSurface.cpp
Date: Fri, 19 Sep 2003 10:43:06 -0400

CVSROOT:        /cvsroot/netpanzer
Module name:    netpanzer
Branch:         
Changes by:     Matthias Braun <address@hidden> 03/09/19 10:43:06

Modified files:
        src/Lib/2D     : PackedSurface.cpp 

Log message:
        use physfs to enumerate files

Patches:
Index: netpanzer/src/Lib/2D/PackedSurface.cpp
diff -u netpanzer/src/Lib/2D/PackedSurface.cpp:1.11 
netpanzer/src/Lib/2D/PackedSurface.cpp:1.12
--- netpanzer/src/Lib/2D/PackedSurface.cpp:1.11 Tue Sep 16 16:16:09 2003
+++ netpanzer/src/Lib/2D/PackedSurface.cpp      Fri Sep 19 10:43:06 2003
@@ -17,6 +17,10 @@
 */
 #include <config.h>
 
+#include <vector>
+#include <string>
+#include <algorithm>
+
 #include "FindFirst.hpp"
 #include "PackedSurface.hpp"
 #include "Surface.hpp"
@@ -586,49 +590,30 @@
 
 // loadAllPAKInDirectory
 //---------------------------------------------------------------------------
-int loadAllPAKInDirectory(const char *path, cGrowList <PackedSurface> 
&growList)
+int loadAllPAKInDirectory(const char *path, cGrowList<PackedSurface> &growList)
 {
-    char strBuf[256];
-    char pathWild[256];
-
-    sprintf(pathWild, "%s*.pak", path);
-
-    int imageCount = UtilInterface::getNumFilesInDirectory(pathWild);
-    if (imageCount <= 0) {
-        return 0;
-    }
-
-    struct _finddata_t myFile;
-    int* hFile;
+    char** list = FileSystem::enumerateFiles(path);
 
-    _findfirst(pathWild, &myFile);
-
-    cGrowList <Filename> filenames;
-    filenames.setNum(imageCount);
-
-    int curFilename = 0;
-    iXY maxSize(0, 0);
-
-    if ((hFile = _findfirst(pathWild, &myFile)) != ((int*) -1)) {
-        do {
-            sprintf(strBuf, "%s%s", path, myFile.name);
-            filenames[curFilename].setName(strBuf);
-            curFilename++;
-
-        } while (_findnext(hFile, &myFile) == 0);
+    std::vector<std::string> filenames;
+    for(char** file = list; *file != 0; file++) {
+       std::string name = path;
+       name += *file;
+       if(name.find(".pak") > 0)
+           filenames.push_back(name);
     }
-    _findclose(hFile);
 
-    filenames.sort(FilenameSortFunction);
+    FileSystem::freeList(list);
+   
+    std::sort(filenames.begin(), filenames.end()); 
 
     // Allocate enough slots into the growList.
-    growList.setNum(imageCount);
+    growList.setNum(filenames.size());
 
     // Now load in the sorted PAK names.
-    for (int i = 0; i < imageCount; i++) {
-        growList[i].load(filenames[i].name);
+    for (size_t i = 0; i < filenames.size(); i++) {
+        growList[i].load(filenames[i].c_str());
     }
 
     return 1;
-
 } // end loadAllPAKInDirectory
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]