diff options
| author | Alexander Gavrilov | 2012-05-05 21:07:18 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-05-05 21:07:18 +0400 |
| commit | 3bd44e5367e6f51b4fb7af854068c67b6f73bb4a (patch) | |
| tree | 3e79e7c613d96fb6f04a154eb43636eec74f7be5 /library/MiscUtils.cpp | |
| parent | 81f2240c237253a7a2264c1b9682a291337667b0 (diff) | |
| download | dfhack-3bd44e5367e6f51b4fb7af854068c67b6f73bb4a.tar.gz dfhack-3bd44e5367e6f51b4fb7af854068c67b6f73bb4a.tar.bz2 dfhack-3bd44e5367e6f51b4fb7af854068c67b6f73bb4a.tar.xz | |
Move some things that won't work in dfhack-client to a separate file.
Diffstat (limited to 'library/MiscUtils.cpp')
| -rw-r--r-- | library/MiscUtils.cpp | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/library/MiscUtils.cpp b/library/MiscUtils.cpp index 65fa21e1..9febe6db 100644 --- a/library/MiscUtils.cpp +++ b/library/MiscUtils.cpp @@ -30,12 +30,9 @@ distribution. #ifndef LINUX_BUILD #include <Windows.h> - #include "wdirent.h" #else #include <sys/time.h> #include <ctime> - #include <dirent.h> - #include <errno.h> #endif #include <ctype.h> @@ -128,90 +125,6 @@ std::string toLower(const std::string &str) return rv; } -int getdir(std::string dir, std::vector<std::string> &files) -{ - DIR *dp; - struct dirent *dirp; - if((dp = opendir(dir.c_str())) == NULL) - { - return errno; - } - while ((dirp = readdir(dp)) != NULL) { - files.push_back(std::string(dirp->d_name)); - } - closedir(dp); - return 0; -} - -bool hasEnding (std::string const &fullString, std::string const &ending) -{ - if (fullString.length() > ending.length()) - { - return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending)); - } - else - { - return false; - } -} - - -df::general_ref *DFHack::findRef(std::vector<df::general_ref*> &vec, df::general_ref_type type) -{ - for (int i = vec.size()-1; i >= 0; i--) - { - df::general_ref *ref = vec[i]; - if (ref->getType() == type) - return ref; - } - - return NULL; -} - -bool DFHack::removeRef(std::vector<df::general_ref*> &vec, df::general_ref_type type, int id) -{ - for (int i = vec.size()-1; i >= 0; i--) - { - df::general_ref *ref = vec[i]; - if (ref->getType() != type || ref->getID() != id) - continue; - - vector_erase_at(vec, i); - delete ref; - return true; - } - - return false; -} - -df::specific_ref *DFHack::findRef(std::vector<df::specific_ref*> &vec, df::specific_ref_type type) -{ - for (int i = vec.size()-1; i >= 0; i--) - { - df::specific_ref *ref = vec[i]; - if (ref->type == type) - return ref; - } - - return NULL; -} - -bool DFHack::removeRef(std::vector<df::specific_ref*> &vec, df::specific_ref_type type, void *ptr) -{ - for (int i = vec.size()-1; i >= 0; i--) - { - df::specific_ref *ref = vec[i]; - if (ref->type != type || ref->object != ptr) - continue; - - vector_erase_at(vec, i); - delete ref; - return true; - } - - return false; -} - #ifdef LINUX_BUILD // Linux uint64_t GetTimeMs64() { |
