NWengine 0.9
Loading...
Searching...
No Matches
Utilities.h
1#pragma once
2#include <string>
3#include <vector>
4
5#ifndef NOMINMAX
6#define NOMINMAX
7#endif
8#define WIN
9
17#define WIN_STR_FILTER(filesType, types) filesType "\0" types "\0All\0*.*\0"
18
26template<typename T>
27void ExtendVector(std::vector<T>* a, const std::vector<T>& b) {
28 for (auto& c : b) {
29 a->push_back(c);
30 }
31}
32
39std::vector<std::string> GetNWlist(std::string path);
40
41//Next functions use windows api; LATETODO:: Add their equivalent for mac, linux etc...
42//#ifdef WIN
43
44/*See Interface.cpp to know these functions role. I could have used only one loop to get number and string but it's cleaner when done like
45* like this and think it won't affect too much engine performance.
46*/
47
52struct DllHandle {
58 DllHandle(const char* filename);
59 DllHandle() {};
60 ~DllHandle();
61
67 const void* Get() const;
68
69private:
70 void* h = nullptr;
71};
72
80void* GetDllFunction(DllHandle* dll, const char* functionName);
81
88std::vector<int> GetRecusivelyFilesNumber(const std::string& directory);
89
97std::vector<std::string> GetDirFiles(const std::string& directory, const std::string& extensionFilter = "");
98
105std::vector<std::string> GetRecusivelyDirFiles(const std::string& directory);
106
115int AccumulateChildren(std::vector<int>* a, std::vector<int>* b, int index = 0);
116
122std::string GetCurrentDir();
123
129std::string GetExePath();
130
137std::string GetFile(const char* type = "Text Files\0*.txt\0*.*\0");
138
145std::string SaveAs(const char* type = "Text Files\0*.txt\0*.*\0");
146
153std::string ToSingleBackSlash(const std::string& dir);
154
161std::string ToDoubleBackSlash(const std::string& dir);
162
172std::string GetFileName(std::string path, std::string* bFilename = nullptr, std::string* bExtension = nullptr, std::string* bRoot = nullptr);
173
181bool CopyDirectory(const std::string& dest, const std::string& src);
182
189bool MakeDir(const std::string& path);
190
197bool MakeFile(const std::string& path);
198
207bool FileCopy(std::string dest, std::string src, bool failIfExists = false);
208
215bool FileExists(std::string dir);
216
223bool Exec(std::string cmd);
224
231bool FileDelete(std::string name);
232
241bool FileMove(std::string dest, std::string source, bool failIfExists = false);
Definition Maths.h:21
A handle to a dynamic-link library (DLL)
Definition Utilities.h:52
const void * Get() const
Get the pointer to the loaded DLL.
Definition Utilities.cpp:27