Tactics: Western Philosophers Vs. Musicians  0.12
A turn-based tactical game combining rules and gameplay elements inspired by Final Fantasy Tactics and the Mayfair Exponential Game System. Unlike most games of this type, motion is in full, grid-less 3D.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UDir.h
Go to the documentation of this file.
1 // Copyright (C) 2010-2014 Dylan Blair
3 //
4 // email: dblair@alumni.cs.utexas.edu
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 
21 #ifndef UDIR_H
22 #define UDIR_H
23 
24 #include <list>
25 #include <string>
26 
27 #ifdef _WIN32
28 #ifndef WIN32_LEAN_AND_MEAN
29 #define WIN32_LEAN_AND_MEAN
30 #endif
31 #include <windows.h>
32 
33 namespace OpenSkyNet {
34  namespace Utils {
35  inline void GetFileNamesInDir(const std::string& dir_, std::list<std::string>& fileNames_) {
36  fileNames_.clear();
37 
38  WIN32_FIND_DATA findData;
39  HANDLE hFind = FindFirstFile((dir_ + "*").c_str(), &findData);
40  if (hFind != INVALID_HANDLE_VALUE) {
41  std::string fileName(findData.cFileName);
42  if (fileName != "." && fileName != "..")
43  fileNames_.push_back(fileName);
44  while (FindNextFile(hFind, &findData)) {
45  std::string fileName(findData.cFileName);
46  if (fileName != "." && fileName != "..")
47  fileNames_.push_back(fileName);
48  }
49  FindClose(hFind);
50  }
51  }
52  }
53 }
54 #else
55 #include <dirent.h>
56 
57 namespace OpenSkyNet {
58  namespace Utils {
59  inline void GetFileNamesInDir(const std::string& dir_, std::list<std::string>& fileNames_) {
60  fileNames_.clear();
61 
62  dirent** nameList;
63  int numNames = scandir(dir_.c_str(), &nameList, 0, alphasort);
64  if (numNames > 0) {
65  for (int i = 0; i < numNames; ++i) {
66  std::string fileName(nameList[i]->d_name);
67  if (fileName != "." && fileName != "..")
68  fileNames_.push_back(fileName);
69  free(nameList[i]);
70  }
71  free(nameList);
72  }
73  }
74  }
75 }
76 #endif
77 
78 #endif //UDIR_H
void GetFileNamesInDir(const std::string &dir_, std::list< std::string > &fileNames_)
Definition: UDir.h:59