compiles on windows
This commit is contained in:
parent
f1c5641ed0
commit
d45b8954d2
|
@ -2,6 +2,7 @@
|
||||||
*.out
|
*.out
|
||||||
build/
|
build/
|
||||||
*.exe
|
*.exe
|
||||||
|
*.dll
|
||||||
*.o
|
*.o
|
||||||
.gdb_history
|
.gdb_history
|
||||||
|
|
||||||
|
|
5
Makefile
5
Makefile
|
@ -5,8 +5,11 @@
|
||||||
# `make clean all` nicht mit -j verwenden! -> race condition im make file
|
# `make clean all` nicht mit -j verwenden! -> race condition im make file
|
||||||
# statdessen: `make clean; make all -j` verwenden
|
# statdessen: `make clean; make all -j` verwenden
|
||||||
|
|
||||||
|
# windows name
|
||||||
|
# NAME = lib$(NAMESHORT).dll
|
||||||
|
|
||||||
NAMESHORT = mrbesen
|
NAMESHORT = mrbesen
|
||||||
NAME = lib$(NAMESHORT).so
|
NAME ?= lib$(NAMESHORT).so
|
||||||
NAMETEST = test
|
NAMETEST = test
|
||||||
CFLAGS = -fpic -std=c++17 -O2 -g -pipe -Wall -Wextra -Wno-unused-parameter -Wpedantic
|
CFLAGS = -fpic -std=c++17 -O2 -g -pipe -Wall -Wextra -Wno-unused-parameter -Wpedantic
|
||||||
CXX = g++
|
CXX = g++
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#include "files.h"
|
#include "files.h"
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -11,6 +11,14 @@
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
#define PATH_MAX 1024
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
void mrbesen::files::parent(const std::string& child, std::string& out) {
|
void mrbesen::files::parent(const std::string& child, std::string& out) {
|
||||||
//letzten path trenner finden
|
//letzten path trenner finden
|
||||||
size_t pos = child.rfind('/', child.length() -2); //das erste Zeichen überspringen (könnte ein / sein)
|
size_t pos = child.rfind('/', child.length() -2); //das erste Zeichen überspringen (könnte ein / sein)
|
||||||
|
@ -147,9 +155,23 @@ bool mrbesen::files::copy(const std::string& from, const std::string& to) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string mrbesen::files::realPath(const std::string& str) {
|
std::string mrbesen::files::realPath(const std::string& str) {
|
||||||
|
#if defined(_WIN32) ||defined(_WIN64)
|
||||||
|
wchar_t bufferin[PATH_MAX];
|
||||||
|
for(uint32_t i = 0; i < str.size(); ++i) {
|
||||||
|
bufferin[i] = str[i];
|
||||||
|
}
|
||||||
|
bufferin[str.size()] = 0;
|
||||||
|
|
||||||
|
wchar_t bufferA[PATH_MAX];
|
||||||
|
wchar_t* ret = ::_wfullpath(bufferA, bufferin, PATH_MAX);
|
||||||
|
char buffer[PATH_MAX];
|
||||||
|
for(uint32_t i = 0; ret[i]; ++i) {
|
||||||
|
buffer[i] = ret[i];
|
||||||
|
}
|
||||||
|
#else
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
char* ret = ::realpath(str.c_str(), buffer);
|
char* ret = ::realpath(str.c_str(), buffer);
|
||||||
|
#endif
|
||||||
if(ret == nullptr) return "";
|
if(ret == nullptr) return "";
|
||||||
|
|
||||||
return std::string(buffer);
|
return std::string(buffer);
|
||||||
}
|
}
|
Loading…
Reference in New Issue