From 99abc01f7cdacd1eae78c3beae1d8c9345cd819a Mon Sep 17 00:00:00 2001 From: Nic Date: Fri, 24 Nov 2017 10:41:51 +0300 Subject: [PATCH] Adds Win32 compatibility --- IntFunc.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/IntFunc.cpp b/IntFunc.cpp index 9b0472e..da046d8 100644 --- a/IntFunc.cpp +++ b/IntFunc.cpp @@ -406,9 +406,13 @@ TValue *map_fclose(void *node, TArgs *args, Context &context) { } TValue *map_project_dir(void *node, TArgs *args, Context &context) { - char *s = cgt->ReadStrParam(PARAM_PROJECT_NAME, context.element); + char *s = cgt->ReadStrParam(PARAM_PROJECT_PATH, context.element); std::string p(s); +#ifdef WIN32 + int pos = p.find_last_of('\\'); +#else int pos = p.find_last_of('/'); +#endif TValue *val = new TValue(p.substr(0, pos+1).c_str(), true); delete[] s; return val; @@ -417,8 +421,13 @@ TValue *map_project_dir(void *node, TArgs *args, Context &context) { TValue *map_project_name(void *node, TArgs *args, Context &context) { char *s = cgt->ReadStrParam(PARAM_PROJECT_NAME, context.element); std::string p(s); +#ifdef WIN32 + int pos = p.find_last_of('\\'); + TValue *val = new TValue(p.substr(pos + 1, p.length() - pos).c_str(), true); +#else int pos = p.find_last_of('/'); TValue *val = new TValue(p.substr(pos + 1, p.length() - pos - 5).c_str(), true); +#endif delete[] s; return val; }