small cleanups to avoid a few ifdef _WIN32
This commit is contained in:
parent
f0efed545d
commit
b118c93b4f
@ -161,7 +161,6 @@ string mimetype(const string &fn, const struct PathStat *stp,
|
|||||||
|
|
||||||
string mtype;
|
string mtype;
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
// Extended attribute has priority on everything, as per:
|
// Extended attribute has priority on everything, as per:
|
||||||
// http://freedesktop.org/wiki/CommonExtendedAttributes
|
// http://freedesktop.org/wiki/CommonExtendedAttributes
|
||||||
if (pxattr::get(fn, "mime_type", &mtype)) {
|
if (pxattr::get(fn, "mime_type", &mtype)) {
|
||||||
@ -172,7 +171,6 @@ string mimetype(const string &fn, const struct PathStat *stp,
|
|||||||
return mtype;
|
return mtype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (cfg == 0) {
|
if (cfg == 0) {
|
||||||
LOGERR("Mimetype: null config ??\n");
|
LOGERR("Mimetype: null config ??\n");
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2004 J.F.Dockes
|
/* Copyright (C) 2004-2022 J.F.Dockes
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
|||||||
@ -69,11 +69,9 @@ bool MimeHandlerText::set_document_file_impl(const string&, const string &fn)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
// Check for charset defined in extended attribute as per:
|
// Check for charset defined in extended attribute as per:
|
||||||
// http://freedesktop.org/wiki/CommonExtendedAttributes
|
// http://freedesktop.org/wiki/CommonExtendedAttributes
|
||||||
pxattr::get(m_fn, "charset", &m_charsetfromxattr);
|
pxattr::get(m_fn, "charset", &m_charsetfromxattr);
|
||||||
#endif
|
|
||||||
|
|
||||||
getparams();
|
getparams();
|
||||||
if (m_maxmbs != -1 && m_totlen / (1024*1024) > m_maxmbs) {
|
if (m_maxmbs != -1 && m_totlen / (1024*1024) > m_maxmbs) {
|
||||||
@ -88,8 +86,7 @@ bool MimeHandlerText::set_document_file_impl(const string&, const string &fn)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MimeHandlerText::set_document_string_impl(const string&,
|
bool MimeHandlerText::set_document_string_impl(const string&, const string& otext)
|
||||||
const string& otext)
|
|
||||||
{
|
{
|
||||||
m_fn.clear();
|
m_fn.clear();
|
||||||
m_totlen = otext.size();
|
m_totlen = otext.size();
|
||||||
|
|||||||
@ -14,8 +14,9 @@
|
|||||||
* Free Software Foundation, Inc.,
|
* Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
#ifdef _WIN32
|
|
||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
|
|
||||||
#include "winschedtool.h"
|
#include "winschedtool.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -97,4 +98,3 @@ void WinSchedToolW::startWinScheduler()
|
|||||||
vector<string> lcmd{"c:/windows/system32/taskschd.msc"};
|
vector<string> lcmd{"c:/windows/system32/taskschd.msc"};
|
||||||
m_cmd->startExec("rclstartw", lcmd, false, false);
|
m_cmd->startExec("rclstartw", lcmd, false, false);
|
||||||
}
|
}
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
|||||||
94
src/testmains/trcopyfile.cpp
Normal file
94
src/testmains/trcopyfile.cpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/* Copyright (C) 2021 J.F.Dockes
|
||||||
|
*
|
||||||
|
* License: GPL 2.1
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program; if not, write to the
|
||||||
|
* Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "copyfile.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
static int op_flags;
|
||||||
|
#define OPT_MOINS 0x1
|
||||||
|
#define OPT_m 0x2
|
||||||
|
#define OPT_e 0x4
|
||||||
|
|
||||||
|
static const char *thisprog;
|
||||||
|
static char usage [] =
|
||||||
|
"trcopyfile [-m] src dst\n"
|
||||||
|
" -m : move instead of copying\n"
|
||||||
|
" -e : fail if dest exists (only for copy)\n"
|
||||||
|
"\n"
|
||||||
|
;
|
||||||
|
static void
|
||||||
|
Usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: usage:\n%s", thisprog, usage);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
thisprog = argv[0];
|
||||||
|
argc--; argv++;
|
||||||
|
|
||||||
|
while (argc > 0 && **argv == '-') {
|
||||||
|
(*argv)++;
|
||||||
|
if (!(**argv))
|
||||||
|
/* Cas du "adb - core" */
|
||||||
|
Usage();
|
||||||
|
while (**argv)
|
||||||
|
switch (*(*argv)++) {
|
||||||
|
case 'm': op_flags |= OPT_m; break;
|
||||||
|
case 'e': op_flags |= OPT_e; break;
|
||||||
|
default: Usage(); break;
|
||||||
|
}
|
||||||
|
argc--; argv++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
Usage();
|
||||||
|
string src = *argv++;argc--;
|
||||||
|
string dst = *argv++;argc--;
|
||||||
|
bool ret;
|
||||||
|
string reason;
|
||||||
|
if (op_flags & OPT_m) {
|
||||||
|
ret = renameormove(src.c_str(), dst.c_str(), reason);
|
||||||
|
} else {
|
||||||
|
int flags = 0;
|
||||||
|
if (op_flags & OPT_e) {
|
||||||
|
flags |= COPYFILE_EXCL;
|
||||||
|
}
|
||||||
|
ret = copyfile(src.c_str(), dst.c_str(), reason, flags);
|
||||||
|
}
|
||||||
|
if (!ret) {
|
||||||
|
cerr << reason << endl;
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
cout << "Succeeded" << endl;
|
||||||
|
if (!reason.empty()) {
|
||||||
|
cout << "Warnings: " << reason << endl;
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
38
src/testmains/trcpuconf.cpp
Normal file
38
src/testmains/trcpuconf.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* Copyright (C) 2021 J.F.Dockes
|
||||||
|
*
|
||||||
|
* License: GPL 2.1
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program; if not, write to the
|
||||||
|
* Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#include "cpuconf.h"
|
||||||
|
|
||||||
|
// Test driver
|
||||||
|
int main(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
CpuConf cpus;
|
||||||
|
if (!getCpuConf(cpus)) {
|
||||||
|
cerr << "getCpuConf failed" << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
cout << "Cpus: " << cpus.ncpus << endl;
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#define O_BINARY 0
|
|
||||||
#else
|
#else
|
||||||
struct iovec {
|
struct iovec {
|
||||||
void *iov_base;
|
void *iov_base;
|
||||||
|
|||||||
@ -14,25 +14,26 @@
|
|||||||
* Free Software Foundation, Inc.,
|
* Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
#ifndef TEST_COPYFILE
|
|
||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
|
|
||||||
|
#include "copyfile.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "safefcntl.h"
|
#include "safefcntl.h"
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "safesysstat.h"
|
#include "safesysstat.h"
|
||||||
#include "safeunistd.h"
|
#include "safeunistd.h"
|
||||||
#include "pathut.h"
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#define O_BINARY 0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "copyfile.h"
|
#include "pathut.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -189,85 +190,3 @@ bool renameormove(const char *src, const char *dst, string &reason)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "copyfile.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
static int op_flags;
|
|
||||||
#define OPT_MOINS 0x1
|
|
||||||
#define OPT_m 0x2
|
|
||||||
#define OPT_e 0x4
|
|
||||||
|
|
||||||
static const char *thisprog;
|
|
||||||
static char usage [] =
|
|
||||||
"trcopyfile [-m] src dst\n"
|
|
||||||
" -m : move instead of copying\n"
|
|
||||||
" -e : fail if dest exists (only for copy)\n"
|
|
||||||
"\n"
|
|
||||||
;
|
|
||||||
static void
|
|
||||||
Usage(void)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: usage:\n%s", thisprog, usage);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
thisprog = argv[0];
|
|
||||||
argc--; argv++;
|
|
||||||
|
|
||||||
while (argc > 0 && **argv == '-') {
|
|
||||||
(*argv)++;
|
|
||||||
if (!(**argv))
|
|
||||||
/* Cas du "adb - core" */
|
|
||||||
Usage();
|
|
||||||
while (**argv)
|
|
||||||
switch (*(*argv)++) {
|
|
||||||
case 'm': op_flags |= OPT_m; break;
|
|
||||||
case 'e': op_flags |= OPT_e; break;
|
|
||||||
default: Usage(); break;
|
|
||||||
}
|
|
||||||
argc--; argv++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc != 2)
|
|
||||||
Usage();
|
|
||||||
string src = *argv++;argc--;
|
|
||||||
string dst = *argv++;argc--;
|
|
||||||
bool ret;
|
|
||||||
string reason;
|
|
||||||
if (op_flags & OPT_m) {
|
|
||||||
ret = renameormove(src.c_str(), dst.c_str(), reason);
|
|
||||||
} else {
|
|
||||||
int flags = 0;
|
|
||||||
if (op_flags & OPT_e) {
|
|
||||||
flags |= COPYFILE_EXCL;
|
|
||||||
}
|
|
||||||
ret = copyfile(src.c_str(), dst.c_str(), reason, flags);
|
|
||||||
}
|
|
||||||
if (!ret) {
|
|
||||||
cerr << reason << endl;
|
|
||||||
exit(1);
|
|
||||||
} else {
|
|
||||||
cout << "Succeeded" << endl;
|
|
||||||
if (!reason.empty()) {
|
|
||||||
cout << "Warnings: " << reason << endl;
|
|
||||||
}
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2013 J.F.Dockes
|
/* Copyright (C) 2013-2022 J.F.Dockes
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -14,11 +14,8 @@
|
|||||||
* Free Software Foundation, Inc.,
|
* Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
#ifndef TEST_CPUCONF
|
|
||||||
|
|
||||||
#include "autoconfig.h"
|
#include "autoconfig.h"
|
||||||
|
|
||||||
|
|
||||||
#include "cpuconf.h"
|
#include "cpuconf.h"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -39,25 +36,3 @@ bool getCpuConf(CpuConf& cpus)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // TEST_CPUCONF
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "cpuconf.h"
|
|
||||||
|
|
||||||
// Test driver
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
CpuConf cpus;
|
|
||||||
if (!getCpuConf(cpus)) {
|
|
||||||
cerr << "getCpuConf failed" << endl;
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
cout << "Cpus: " << cpus.ncpus << endl;
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
#endif // TEST_CPUCONF
|
|
||||||
|
|||||||
@ -171,7 +171,6 @@
|
|||||||
#define DIRENT dirent
|
#define DIRENT dirent
|
||||||
#define DIRHDL DIR
|
#define DIRHDL DIR
|
||||||
#define MKDIR(a,b) mkdir(a,b)
|
#define MKDIR(a,b) mkdir(a,b)
|
||||||
#define O_BINARY 0
|
|
||||||
#define OPEN ::open
|
#define OPEN ::open
|
||||||
#define UNLINK ::unlink
|
#define UNLINK ::unlink
|
||||||
#define RMDIR ::rmdir
|
#define RMDIR ::rmdir
|
||||||
|
|||||||
@ -81,6 +81,8 @@ bool path_exists(const std::string& path);
|
|||||||
bool path_readable(const std::string& path);
|
bool path_readable(const std::string& path);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
// Constants for _waccess()
|
||||||
# ifndef R_OK
|
# ifndef R_OK
|
||||||
# define R_OK 4
|
# define R_OK 4
|
||||||
# endif
|
# endif
|
||||||
@ -94,7 +96,30 @@ bool path_readable(const std::string& path);
|
|||||||
# ifndef F_OK
|
# ifndef F_OK
|
||||||
# define F_OK 0
|
# define F_OK 0
|
||||||
# endif
|
# endif
|
||||||
#endif /* _WIN32 */
|
|
||||||
|
// Conversion between utf-8 and wide char file names.
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
bool wchartoutf8(const wchar_t *in, std::string& out, size_t len = 0);
|
||||||
|
std::string wchartoutf8(const wchar_t *in, size_t len = 0);
|
||||||
|
bool utf8towchar(const std::string& in, wchar_t *out, size_t obytescap);
|
||||||
|
std::unique_ptr<wchar_t[]> utf8towchar(const std::string& in);
|
||||||
|
|
||||||
|
// Convert between slash and backslash separators.
|
||||||
|
void path_slashize(std::string& s);
|
||||||
|
void path_backslashize(std::string& s);
|
||||||
|
|
||||||
|
extern std::string path_shortpath(const std::string& path);
|
||||||
|
|
||||||
|
#else // !_WIN32 ->
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#define path_shortpath(path) (path)
|
||||||
|
#ifndef O_BINARY
|
||||||
|
#define O_BINARY 0
|
||||||
|
#endif
|
||||||
|
#endif /* !_WIN32 */
|
||||||
|
|
||||||
/// access() or _waccess()
|
/// access() or _waccess()
|
||||||
bool path_access(const std::string& path, int mode);
|
bool path_access(const std::string& path, int mode);
|
||||||
|
|
||||||
@ -125,14 +150,6 @@ extern int path_fileprops(const std::string path, struct PathStat *stp,
|
|||||||
/// Return separator for PATH environment variable
|
/// Return separator for PATH environment variable
|
||||||
extern std::string path_PATHsep();
|
extern std::string path_PATHsep();
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <memory>
|
|
||||||
bool wchartoutf8(const wchar_t *in, std::string& out, size_t len = 0);
|
|
||||||
std::string wchartoutf8(const wchar_t *in, size_t len = 0);
|
|
||||||
bool utf8towchar(const std::string& in, wchar_t *out, size_t obytescap);
|
|
||||||
std::unique_ptr<wchar_t[]> utf8towchar(const std::string& in);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Directory reading interface. UTF-8 on Windows.
|
/// Directory reading interface. UTF-8 on Windows.
|
||||||
class PathDirContents {
|
class PathDirContents {
|
||||||
public:
|
public:
|
||||||
@ -219,15 +236,6 @@ public:
|
|||||||
std::string fragment;
|
std::string fragment;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
/// Convert \ separators to /
|
|
||||||
void path_slashize(std::string& s);
|
|
||||||
void path_backslashize(std::string& s);
|
|
||||||
extern std::string path_shortpath(const std::string& path);
|
|
||||||
#else
|
|
||||||
#define path_shortpath(path) (path)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/// Lock/pid file class. This is quite close to the pidfile_xxx
|
/// Lock/pid file class. This is quite close to the pidfile_xxx
|
||||||
/// utilities in FreeBSD with a bit more encapsulation. I'd have used
|
/// utilities in FreeBSD with a bit more encapsulation. I'd have used
|
||||||
/// the freebsd code if it was available elsewhere
|
/// the freebsd code if it was available elsewhere
|
||||||
|
|||||||
@ -1,36 +1,36 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2009 Jean-Francois Dockes
|
Copyright (c) 2009 Jean-Francois Dockes
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
obtaining a copy of this software and associated documentation
|
||||||
files (the "Software"), to deal in the Software without
|
files (the "Software"), to deal in the Software without
|
||||||
restriction, including without limitation the rights to use,
|
restriction, including without limitation the rights to use,
|
||||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the
|
copies of the Software, and to permit persons to whom the
|
||||||
Software is furnished to do so, subject to the following
|
Software is furnished to do so, subject to the following
|
||||||
conditions:
|
conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
The above copyright notice and this permission notice shall be
|
||||||
included in all copies or substantial portions of the Software.
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
OTHER DEALINGS IN THE SOFTWARE.
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \file pxattr.cpp
|
/** \file pxattr.cpp
|
||||||
\brief Portable External Attributes API
|
\brief Portable External Attributes API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// PXALINUX: platforms like kfreebsd which aren't linux but use the
|
// PXALINUX: platforms like kfreebsd which aren't linux but use the
|
||||||
// same xattr interface
|
// same xattr interface
|
||||||
#if defined(__linux__) || \
|
#if defined(__linux__) || \
|
||||||
(defined(__FreeBSD_kernel__)&&defined(__GLIBC__)&&!defined(__FreeBSD__)) ||\
|
(defined(__FreeBSD_kernel__)&&defined(__GLIBC__)&&!defined(__FreeBSD__)) || \
|
||||||
defined(__CYGWIN__)
|
defined(__CYGWIN__)
|
||||||
#define PXALINUX
|
#define PXALINUX
|
||||||
#endif
|
#endif
|
||||||
@ -44,7 +44,9 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
// just let the methods return errors (like they would on a non-xattr
|
// just let the methods return errors (like they would on a non-xattr
|
||||||
// fs on e.g. linux)
|
// fs on e.g. linux)
|
||||||
|
|
||||||
#if defined(__DragonFly__) || defined(__OpenBSD__)
|
// Not exactly true for win32, but makes my life easier by avoiding ifdefs in recoll (the calls just
|
||||||
|
// fail, which is expected)
|
||||||
|
#if defined(__DragonFly__) || defined(__OpenBSD__) || defined(_WIN32)
|
||||||
#define HAS_NO_XATTR
|
#define HAS_NO_XATTR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -752,21 +754,21 @@ static void restore(const char *backupnm)
|
|||||||
|
|
||||||
static char *thisprog;
|
static char *thisprog;
|
||||||
static char usage [] =
|
static char usage [] =
|
||||||
"pxattr [-hs] -n name pathname [...] : show value for name\n"
|
"pxattr [-hs] -n name pathname [...] : show value for name\n"
|
||||||
"pxattr [-hs] -n name -r regexp pathname [...] : test value against regexp\n"
|
"pxattr [-hs] -n name -r regexp pathname [...] : test value against regexp\n"
|
||||||
"pxattr [-hs] -n name -v value pathname [...] : add/replace attribute\n"
|
"pxattr [-hs] -n name -v value pathname [...] : add/replace attribute\n"
|
||||||
"pxattr [-hs] -x name pathname [...] : delete attribute\n"
|
"pxattr [-hs] -x name pathname [...] : delete attribute\n"
|
||||||
"pxattr [-hs] [-l] [-R] pathname [...] : list attribute names and values\n"
|
"pxattr [-hs] [-l] [-R] pathname [...] : list attribute names and values\n"
|
||||||
" For all the options above, if no pathname arguments are given, pxattr\n"
|
" For all the options above, if no pathname arguments are given, pxattr\n"
|
||||||
" will read file names on stdin, one per line.\n"
|
" will read file names on stdin, one per line.\n"
|
||||||
" [-h] : don't follow symbolic links (act on link itself)\n"
|
" [-h] : don't follow symbolic links (act on link itself)\n"
|
||||||
" [-R] : recursive listing. Args should be directory(ies)\n"
|
" [-R] : recursive listing. Args should be directory(ies)\n"
|
||||||
" [-s] : be silent. With one option stdout is suppressed, with 2 stderr too\n"
|
" [-s] : be silent. With one option stdout is suppressed, with 2 stderr too\n"
|
||||||
"pxattr -S <backupfile> Restore xattrs from file created by pxattr -lR output\n"
|
"pxattr -S <backupfile> Restore xattrs from file created by pxattr -lR output\n"
|
||||||
" if backupfile is 'stdin', reads from stdin\n"
|
" if backupfile is 'stdin', reads from stdin\n"
|
||||||
"pxattr -T: run tests on temp file in current directory"
|
"pxattr -T: run tests on temp file in current directory"
|
||||||
"\n"
|
"\n"
|
||||||
;
|
;
|
||||||
static void
|
static void
|
||||||
Usage(void)
|
Usage(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -35,7 +35,7 @@
|
|||||||
#define OPEN _wopen
|
#define OPEN _wopen
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define O_BINARY 0
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|||||||
@ -24,12 +24,6 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# include "safeunistd.h"
|
|
||||||
#else // Not windows ->
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
int wipedir(const std::string& dir, bool selfalso, bool recurse)
|
int wipedir(const std::string& dir, bool selfalso, bool recurse)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user