From 9e540db7d6492168cadcafddbf145ffdd7b21981 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 23 Jul 2017 10:47:10 -0400 Subject: source cleanup; beginning of custom attacks --- src/common.cpp | 116 --------------------------------------------------------- 1 file changed, 116 deletions(-) (limited to 'src/common.cpp') diff --git a/src/common.cpp b/src/common.cpp index b3b8ec4..df382d8 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1,25 +1,8 @@ #include -#include #include #include #include -#include -#include -#include -#include -#include - -#include -#include - -#ifndef __WIN32__ - -#include -#include -#include - -#endif // __WIN32__ unsigned int millis(void) { using namespace std::chrono; @@ -28,26 +11,6 @@ unsigned int millis(void) { return duration_cast(now.time_since_epoch()).count(); } - -vec2 str2coord(std::string s) -{ - auto cpos = s.find(','); - s[cpos] = '\0'; - return vec2 (std::stof(s), std::stof(s.substr(cpos + 1))); -} - -std::vector StringTokenizer(const std::string& str, char delim) -{ - std::vector tokens; - std::istringstream is (str); - std::string token; - - while (getline(is, token, delim)) - tokens.emplace_back(token); - - return tokens; -} - void DEBUG_prints(const char* file, int line, const char *s,...) { va_list args; @@ -57,82 +20,3 @@ void DEBUG_prints(const char* file, int line, const char *s,...) va_end(args); } -int getdir(std::string dir, std::list& files) -{ -#ifndef __WIN32__ - auto dp = opendir(dir.c_str()); - UserAssert(dp != nullptr, "Couldn\'t open folder: " + dir); - - auto dirp = readdir(dp); - while (dirp != nullptr) { - files.emplace_back(dirp->d_name); - dirp = readdir(dp); - } - - closedir(dp); -#else - WIN32_FIND_DATA fileData; - auto dirh = FindFirstFile((dir + "/*").c_str(), &fileData); - UserAssert(dirh != INVALID_HANDLE_VALUE, "Couldn\'t open folder: " + dir); - - do { - auto fileName = fileData.cFileName; - - if (fileName[0] == '.') - continue; - - if (!(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - files.emplace_back(fileName); - } while (FindNextFile(dirh, &fileData)); - - FindClose(dirh); -#endif // __WIN32__ - - files.sort(); - return 0; -} - -std::string readFile(const std::string& path) -{ - std::ifstream in (path, std::ios::in); - std::string buffer; - - UserAssert(in.is_open(), "Error reading file " + path); - - in.seekg(0, in.end); - buffer.resize(in.tellg()); - in.seekg(0, in.beg); - in.read(&buffer[0], buffer.size()); - - in.close(); - return buffer; -} - -std::vector readFileA(const std::string& path) -{ - std::ifstream in (path, std::ios::in); - std::vector lines; - std::string line; - - UserAssert(in.is_open(), "Error reading file " + path); - - while(std::getline(in, line)) - lines.push_back(line); - - in.close(); - return lines; -} - -void copyFile(const std::string& to, const std::string& from) -{ - std::ifstream src (from, std::ios::binary); - std::ofstream dst (to, std::ios::binary); - dst << src.rdbuf(); -} - -bool fileExists(const std::string& file) -{ - std::ifstream f (file); - return f.good(); -} - -- cgit v1.2.3