Page MenuHomePhabricator (Chris)

No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
diff --git a/util/windows/funcs.cpp b/util/windows/funcs.cpp
new file mode 100644
index 00000000..80c6b096
--- /dev/null
+++ b/util/windows/funcs.cpp
@@ -0,0 +1,21 @@
+#ifdef WINDOWS
+
+#include <windows.h>
+#include "util/funcs.h"
+#include <io.h>
+#include <fcntl.h>
+
+int Util::getPipe(int files[2]){
+ HANDLE read_in, write_in;
+ int ok = CreatePipe(&read_in, &write_in, NULL, 0);
+ if (ok == 0){
+ return -1;
+ }
+ // files[0] = _open_osfhandle(read_in, O_RDONLY | O_BINARY);
+ // files[1] = _open_osfhandle(write_in, O_WRONLY | O_BINARY);
+ files[0] = _open_osfhandle((intptr_t) read_in, _O_RDONLY);
+ files[1] = _open_osfhandle((intptr_t) write_in, _O_WRONLY);
+ return 0;
+}
+
+#endif
diff --git a/util/windows/game.res b/util/windows/game.res
new file mode 100644
index 00000000..3fa61ee5
Binary files /dev/null and b/util/windows/game.res differ
diff --git a/util/windows/system.cpp b/util/windows/system.cpp
new file mode 100644
index 00000000..66924eea
--- /dev/null
+++ b/util/windows/system.cpp
@@ -0,0 +1,76 @@
+#ifdef WINDOWS
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <windows.h>
+#include <psapi.h>
+#include <fstream>
+#include "util/system.h"
+#include <dirent.h>
+
+namespace System{
+
+bool isDirectory(const std::string & path){
+ unsigned int f = GetFileAttributes(path.c_str());
+ if (f == INVALID_FILE_ATTRIBUTES){
+ return false;
+ }
+ return f & FILE_ATTRIBUTE_DIRECTORY;
+}
+
+bool readableFile(const std::string & path){
+ return !isDirectory(path) && readable(path);
+}
+
+bool readable(const std::string & path){
+ if (isDirectory(path)){
+ return true;
+ }
+
+ std::ifstream stream(path.c_str());
+ bool ok = stream.good();
+ if (stream.is_open()){
+ stream.close();
+ }
+ return ok;
+}
+
+void makeDirectory(const std::string & path){
+ _mkdir(path.c_str());
+}
+
+uint64_t currentMicroseconds(){
+ LARGE_INTEGER ticksPerSecond;
+ LARGE_INTEGER tick;
+ QueryPerformanceFrequency(&ticksPerSecond);
+ QueryPerformanceCounter(&tick);
+ return (tick.QuadPart)/(ticksPerSecond.QuadPart/1000000);
+}
+
+uint64_t getModificationTime(const std::string & path){
+ struct _stat info;
+ if (_stat(path.c_str(), &info) == 0){
+ return info.st_mtime;
+ }
+ return 0;
+}
+
+unsigned long memoryUsage(){
+ HANDLE id = GetCurrentProcess();
+ PROCESS_MEMORY_COUNTERS info;
+ BOOL okay = GetProcessMemoryInfo(id, &info, sizeof(info));
+ if (okay){
+ return info.WorkingSetSize;
+ }
+ return 0;
+}
+
+/* call startMemoryUsage once at the very beginning of the program */
+void startMemoryUsage(){
+ /* FIXME */
+}
+
+
+}
+
+#endif

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jun 11, 11:48 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
68870
Default Alt Text
(2 KB)

Event Timeline