diff options
Diffstat (limited to '')
-rw-r--r-- | source/StringUtils.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/source/StringUtils.cpp b/source/StringUtils.cpp index c9dbb1113..1e629c25f 100644 --- a/source/StringUtils.cpp +++ b/source/StringUtils.cpp @@ -159,3 +159,47 @@ void ReplaceString(AString & iHayStack, const AString & iNeedle, const AString & +AStringList GetDirectoryContents(const char * a_Directory)
+{
+ AStringList AllFiles;
+
+ #ifdef _WIN32
+
+ AString FileFilter = AString(a_Directory) + "*.*";
+ HANDLE hFind;
+ WIN32_FIND_DATA FindFileData;
+
+ if ((hFind = FindFirstFile(FileFilter.c_str(), &FindFileData)) != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ AllFiles.push_back(FindFileData.cFileName);
+ } while (FindNextFile(hFind, &FindFileData));
+ FindClose(hFind);
+ }
+
+ #else // _WIN32
+
+ DIR * dp;
+ struct dirent *dirp;
+ if ((dp = opendir(a_Directory)) == NULL)
+ {
+ LOGERROR("Error (%i) opening %s\n", errno, a_Directory );
+ }
+ else
+ {
+ while ((dirp = readdir(dp)) != NULL)
+ {
+ AllFiles.push_back(dirp->d_name);
+ }
+ closedir(dp);
+ }
+
+ #endif // else _WIN32
+
+ return AllFiles;
+}
+
+
+
+
|