WSL/SLF GitLab Repository

Commit 63224b24 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The IMPORT feature in Config now works properly on Windows. It is also now...

The IMPORT feature in Config now works properly on Windows. It is also now possible to call IMPORT_BEFORE from within a section (but it still needs to be the first key in a file). 
parent c02d0f1f
......@@ -205,7 +205,6 @@ void Config::parseLine(const unsigned int& linenr, std::vector<std::string> &imp
//if this is a section header, read it
if(line[0] == '[') {
accept_import_before = false; //this is not an import, so no further imports allowed
const size_t endpos = line.find_last_of(']');
if ((endpos == string::npos) || (endpos < 2) || (endpos != (line.length()-1))) {
stringstream tmp;
......@@ -226,14 +225,14 @@ void Config::parseLine(const unsigned int& linenr, std::vector<std::string> &imp
if(!accept_import_before)
throw IOException("Error in \""+sourcename+"\": IMPORT_BEFORE key MUST occur before any other key!", AT);
if(std::find(imported.begin(), imported.end(), file_and_path)!=imported.end())
throw IOException("Can not import again \"" + value + "\": it has already been imported!", AT);
throw IOException("Can not import \"" + value + "\" again: it has already been imported!", AT);
parseFile(file_and_path);
return;
}
if(key=="IMPORT_AFTER") {
const std::string file_and_path = clean_import_path(value);
if(std::find(imported.begin(), imported.end(), file_and_path)!=imported.end())
throw IOException("Can not import again \"" + value + "\": it has already been imported!", AT);
throw IOException("Can not import \"" + value + "\" again: it has already been imported!", AT);
import_after.push_back(file_and_path);
return;
}
......
......@@ -25,7 +25,8 @@
#include <meteoio/MeteoData.h> // to avoid forward declaration hell
#ifdef WIN32
#include <windows.h>
#include <windows.h>
#include "Shlwapi.h"
//removing two macros defined in windows.h
#undef max
#undef min
......@@ -129,11 +130,13 @@ std::string cleanPath(const std::string& in_path, const bool& resolve)
std::replace(out_path.begin(), out_path.end(), '\\', '/');
return out_path;
} else {
#ifdef WIN32
char out_buff[MAX_PATH], in_buff = in_path.c_str();
char *ptr1 = out_buff, *ptr2 = in_buff;
std::string out_path = (PathCanonicalize(ptr1,ptr2))? ptr1 : in_path;
#ifdef WIN32
char **ptr = NULL;
char *out_buff = (char*)calloc(MAX_PATH, sizeof(char));
const DWORD status = GetFullPathName(in_path.c_str(), MAX_PATH, out_buff, ptr);
std::string out_path = (status!=0 && status<=MAX_PATH)? out_buff : in_path;
free(out_buff);
std::replace(out_path.begin(), out_path.end(), '\\', '/');
return out_path;
#else //POSIX
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment