summaryrefslogtreecommitdiffstats
path: root/source/StringUtils.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-25 16:24:51 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-25 16:24:51 +0200
commitba5b6ca75187e18942c463f7300b49061ebdc183 (patch)
tree99eb3efbb60791ed19d64bab32ee86444ee1fc46 /source/StringUtils.cpp
parentFixed the Log altogether (doesn't use NULL-to-va_list assignment, compiles for RaspberryPi) (diff)
downloadcuberite-ba5b6ca75187e18942c463f7300b49061ebdc183.tar
cuberite-ba5b6ca75187e18942c463f7300b49061ebdc183.tar.gz
cuberite-ba5b6ca75187e18942c463f7300b49061ebdc183.tar.bz2
cuberite-ba5b6ca75187e18942c463f7300b49061ebdc183.tar.lz
cuberite-ba5b6ca75187e18942c463f7300b49061ebdc183.tar.xz
cuberite-ba5b6ca75187e18942c463f7300b49061ebdc183.tar.zst
cuberite-ba5b6ca75187e18942c463f7300b49061ebdc183.zip
Diffstat (limited to '')
-rw-r--r--source/StringUtils.cpp44
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;
+}
+
+
+
+