Add compatibility layer for env setting.
This commit is contained in:
parent
677bfb4020
commit
a222773214
2 changed files with 18 additions and 1 deletions
3
main.cpp
3
main.cpp
|
@ -10,6 +10,7 @@
|
|||
#include <lib.h>
|
||||
#include <stdlib.h>
|
||||
#include <filesystem>
|
||||
#include "win32compat.h"
|
||||
#include "bitmapx16.h"
|
||||
using std::vector;
|
||||
using std::map;
|
||||
|
@ -65,7 +66,7 @@ int main(int argc, char **argv) {
|
|||
bool probe_only = false;
|
||||
std::filesystem::path executable_path = std::filesystem::weakly_canonical(*argv).parent_path();
|
||||
#ifdef _WIN32
|
||||
_setenv("MAGICK_CODER_MODULE_PATH", executable_path.c_str(), 0);
|
||||
setenv("MAGICK_CODER_MODULE_PATH", executable_path.c_str(), 0);
|
||||
#endif
|
||||
InitializeMagick(*argv);
|
||||
argc--;
|
||||
|
|
16
win32compat.h
Normal file
16
win32compat.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <stdlib.h>
|
||||
inline void setenv(char const *variable, char const *value, bool replace) {
|
||||
if (replace || getenv(variable) == NULL || getenv(variable) == "") {
|
||||
if (value == NULL) {
|
||||
_putenv_s(variable, "");
|
||||
} else {
|
||||
_putenv_s(variable, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
Loading…
Reference in a new issue