Skip to content
Snippets Groups Projects
Commit 3b2b66c6 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Andreas Traczyk
Browse files

daemon: add Microsoft libgen port

Add replace dirname with _splitpath to facilitate native Windows
building.

Change-Id: I57712f9f9642c221555b522c312484fed0012f03
Tuleap: #797
parent c221eb0e
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,9 @@ ...@@ -42,7 +42,9 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef WIN32_NATIVE
#include <libgen.h> #include <libgen.h>
#endif
#ifdef WIN32_NATIVE #ifdef WIN32_NATIVE
#include "windirent.h" #include "windirent.h"
...@@ -355,11 +357,13 @@ static std::string cache_path; ...@@ -355,11 +357,13 @@ static std::string cache_path;
static std::string config_path; static std::string config_path;
#else #else
static char *program_dir = NULL; static char *program_dir = NULL;
#ifndef WIN32_NATIVE
void set_program_dir(char *program_path) void set_program_dir(char *program_path)
{ {
program_dir = dirname(program_path); program_dir = dirname(program_path);
} }
#endif #endif
#endif
std::string std::string
get_cache_dir() get_cache_dir()
......
...@@ -44,7 +44,11 @@ ...@@ -44,7 +44,11 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifndef WIN32_NATIVE
#include <libgen.h> #include <libgen.h>
#endif
#ifndef _WIN32 #ifndef _WIN32
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
...@@ -843,7 +847,12 @@ TlsValidator::CheckResult TlsValidator::privateKeyDirectoryPermissions() ...@@ -843,7 +847,12 @@ TlsValidator::CheckResult TlsValidator::privateKeyDirectoryPermissions()
return TlsValidator::CheckResult(CheckValues::UNSUPPORTED, ""); return TlsValidator::CheckResult(CheckValues::UNSUPPORTED, "");
char* dup = strdup(privateKeyPath_.c_str()); char* dup = strdup(privateKeyPath_.c_str());
#ifndef WIN32_NATIVE
const char* dir = dirname(dup); const char* dir = dirname(dup);
#else
char* dir;
_splitpath(certificatePath_.c_str(), nullptr, dir, nullptr, nullptr);
#endif
struct stat statbuf; struct stat statbuf;
int err = stat(dir, &statbuf); int err = stat(dir, &statbuf);
...@@ -861,7 +870,12 @@ TlsValidator::CheckResult TlsValidator::privateKeyDirectoryPermissions() ...@@ -861,7 +870,12 @@ TlsValidator::CheckResult TlsValidator::privateKeyDirectoryPermissions()
TlsValidator::CheckResult TlsValidator::publicKeyDirectoryPermissions() TlsValidator::CheckResult TlsValidator::publicKeyDirectoryPermissions()
{ {
char* dup = strdup(certificatePath_.c_str()); char* dup = strdup(certificatePath_.c_str());
#ifndef WIN32_NATIVE
const char* dir = dirname(dup); const char* dir = dirname(dup);
#else
char* dir;
_splitpath(certificatePath_.c_str(), nullptr, dir, nullptr, nullptr);
#endif
struct stat statbuf; struct stat statbuf;
int err = stat(dir, &statbuf); int err = stat(dir, &statbuf);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment