_WIN32 ifdefs cleanup
This commit is contained in:
parent
5631554abd
commit
66bc94d1e8
10 changed files with 25 additions and 36 deletions
|
@ -47,6 +47,7 @@ typedef int ssize_t;
|
|||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#define ftruncate _chsize_s
|
||||
#define chdir _chdir
|
||||
#define PATH_MAX MAX_PATH
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#define R_OK 4
|
||||
|
|
|
@ -459,14 +459,10 @@ void RclConfig::initThrConf()
|
|||
if (vq.size() > 0 && vq[0] == 0) {
|
||||
LOGDEB(("RclConfig::initThrConf: autoconf requested\n"));
|
||||
CpuConf cpus;
|
||||
#ifdef _WIN32
|
||||
cpus.ncpus = 1;
|
||||
#else
|
||||
if (!getCpuConf(cpus) || cpus.ncpus < 1) {
|
||||
LOGERR(("RclConfig::initThrConf: could not retrieve cpu conf\n"));
|
||||
cpus.ncpus = 1;
|
||||
}
|
||||
#endif
|
||||
// Arbitrarily set threads config based on number of CPUS. This also
|
||||
// depends on the IO setup actually, so we're bound to be wrong...
|
||||
if (cpus.ncpus == 1) {
|
||||
|
|
|
@ -31,9 +31,7 @@
|
|||
#include "pathut.h"
|
||||
#include "unac.h"
|
||||
#include "smallut.h"
|
||||
#ifndef _WIN32
|
||||
#include "execmd.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
static const int catchedSigs[] = {SIGINT, SIGQUIT, SIGTERM, SIGUSR1, SIGUSR2};
|
||||
|
|
|
@ -494,7 +494,7 @@ int main(int argc, char **argv)
|
|||
if ((op_flags & OPT_E)) {
|
||||
exit(0);
|
||||
}
|
||||
#ifndef _WIN32
|
||||
|
||||
string rundir;
|
||||
config->getConfParam("idxrundir", rundir);
|
||||
if (!rundir.compare("tmp")) {
|
||||
|
@ -512,7 +512,6 @@ int main(int argc, char **argv)
|
|||
rundir.c_str(), errno));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool rezero((op_flags & OPT_z) != 0);
|
||||
bool inPlaceReset((op_flags & OPT_Z) != 0);
|
||||
|
|
|
@ -62,7 +62,6 @@ bool getCpuConf(CpuConf& cpus)
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
#else // TEST_CPUCONF
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -22,10 +22,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifndef _WIN32
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include <safefcntl.h> // in case O_APPEND is in there
|
||||
#ifdef INCLUDE_NEW_H
|
||||
#include <new.h>
|
||||
#endif
|
||||
|
|
|
@ -250,6 +250,14 @@ bool maketmpdir(string& tdir, string& reason)
|
|||
return false;
|
||||
}
|
||||
|
||||
// There is a race condition between name computation and
|
||||
// mkdir. try to make sure that we at least don't shoot ourselves
|
||||
// in the foot
|
||||
#if !defined(HAVE_MKDTEMP) || defined(_WIN32)
|
||||
static PTMutexInit mlock;
|
||||
PTMutexLocker lock(mlock);
|
||||
#endif
|
||||
|
||||
if (!
|
||||
#ifdef HAVE_MKDTEMP
|
||||
mkdtemp(cp)
|
||||
|
@ -265,8 +273,6 @@ bool maketmpdir(string& tdir, string& reason)
|
|||
}
|
||||
tdir = cp;
|
||||
free(cp);
|
||||
// At this point the directory does not exist yet if mktemp was used
|
||||
|
||||
#else // _WIN32
|
||||
// There is a race condition between name computation and
|
||||
// mkdir. try to make sure that we at least don't shoot ourselves
|
||||
|
@ -276,6 +282,9 @@ bool maketmpdir(string& tdir, string& reason)
|
|||
tdir = path_wingettempfilename(TEXT("rcltmp"));
|
||||
#endif
|
||||
|
||||
// At this point the directory does not exist yet except if we used
|
||||
// mkdtemp
|
||||
|
||||
#if !defined(HAVE_MKDTEMP) || defined(_WIN32)
|
||||
if (mkdir(tdir.c_str(), 0700) < 0) {
|
||||
reason = string("maketmpdir: mkdir ") + tdir + " failed";
|
||||
|
@ -290,6 +299,13 @@ bool maketmpdir(string& tdir, string& reason)
|
|||
TempFileInternal::TempFileInternal(const string& suffix)
|
||||
: m_noremove(false)
|
||||
{
|
||||
// Because we need a specific suffix, can't use mkstemp
|
||||
// well. There is a race condition between name computation and
|
||||
// file creation. try to make sure that we at least don't shoot
|
||||
// our own selves in the foot. maybe we'll use mkstemps one day.
|
||||
static PTMutexInit mlock;
|
||||
PTMutexLocker lock(mlock);
|
||||
|
||||
#ifndef _WIN32
|
||||
string filename = path_cat(tmplocation(), "rcltmpfXXXXXX");
|
||||
char *cp = strdup(filename.c_str());
|
||||
|
@ -298,8 +314,8 @@ TempFileInternal::TempFileInternal(const string& suffix)
|
|||
return;
|
||||
}
|
||||
|
||||
// Yes using mkstemp this way is awful (bot the suffix adding and
|
||||
// using mkstemp() just to avoid the warnings)
|
||||
// Using mkstemp this way is awful (bot the suffix adding and
|
||||
// using mkstemp() instead of mktemp just to avoid the warnings)
|
||||
int fd;
|
||||
if ((fd = mkstemp(cp)) < 0) {
|
||||
free(cp);
|
||||
|
@ -311,11 +327,6 @@ TempFileInternal::TempFileInternal(const string& suffix)
|
|||
filename = cp;
|
||||
free(cp);
|
||||
#else
|
||||
// There is a race condition between name computation and
|
||||
// mkdir. try to make sure that we at least don't shoot ourselves
|
||||
// in the foot
|
||||
static PTMutexInit mlock;
|
||||
PTMutexLocker lock(mlock);
|
||||
string filename = path_wingettempfilename(TEXT("recoll"));
|
||||
#endif
|
||||
|
||||
|
|
|
@ -97,11 +97,6 @@ extern bool maketmpdir(std::string& tdir, std::string& reason);
|
|||
/// mkdir -p
|
||||
extern bool makepath(const std::string& path);
|
||||
|
||||
#ifdef _WIN32
|
||||
/// Convert \ separators to /
|
||||
extern void path_slashize(std::string& s);
|
||||
#endif
|
||||
|
||||
/// Sub-directory for default recoll config (e.g: .recoll)
|
||||
extern std::string path_defaultrecollconfsubdir();
|
||||
/// Where we create the user data subdirs
|
||||
|
|
|
@ -21,12 +21,7 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
static inline unsigned int sleep(unsigned int s) {Sleep(s * 1000); return 0;}
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "safeunistd.h"
|
||||
|
||||
#include "workqueue.h"
|
||||
|
||||
|
|
|
@ -34,9 +34,7 @@
|
|||
#ifdef _MSC_VER
|
||||
// MSVC #define-s open but also defines a function called open, so just undef
|
||||
// the macro.
|
||||
// Jf/recoll: don't do this, open() seems to be finally deprecated in vs 2015, we need _open(). Hopefully recoll has
|
||||
// no open() methods..
|
||||
//# undef open
|
||||
# undef open
|
||||
#else
|
||||
|
||||
inline int fcntl_open_(const char *filename, int flags, mode_t mode) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue