*/
+#include "config.h"
+
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <algorithm>
#include <boost/thread.hpp>
-#include "config.h"
#include "snapper/Log.h"
#include "snapper/AppUtil.h"
#include "snapper/File.h"
#include "snapper/Compare.h"
#include "snapper/Exception.h"
-
-
-#ifdef ENABLE_XATTRS
- #include "snapper/XAttributes.h"
-#endif
+#include "snapper/XAttributes.h"
namespace snapper
}
#ifdef ENABLE_XATTRS
- if (file1.xaSupported() && file2.xaSupported())
- {
- if (!cmpFilesXattrs(file1, file2))
- {
- status |= XATTRS;
- }
- }
+ if (file1.xaSupported() && file2.xaSupported())
+ {
+ if (!cmpFilesXattrs(file1, file2))
+ {
+ status |= XATTRS;
+ }
+ }
#endif
return status;
}
-#ifdef ENABLE_XATTRS
-
bool
cmpFilesXattrs(const SFile& file1, const SFile& file2)
{
}
}
-#endif
-
}
void
cmpDirs(const SDir& dir1, const SDir& dir2, cmpdirs_cb_t cb);
-#ifdef ENABLE_XATTRS
bool
cmpFilesXattrs(const SFile&, const SFile&);
-#endif
+
}
*/
+#include "config.h"
+
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
-#include "config.h"
#include "snapper/Comparison.h"
#include "snapper/Snapper.h"
#include "snapper/Log.h"
return files.getUndoStatistic();
}
-#ifdef ENABLE_XATTRS
+
XAUndoStatistic
Comparison::getXAUndoStatistic() const
{
return files.getXAUndoStatistic();
}
-#endif
vector<UndoStep>
void umount() const;
UndoStatistic getUndoStatistic() const;
-#ifdef ENABLE_XATTRS
XAUndoStatistic getXAUndoStatistic() const;
-#endif
vector<UndoStep> getUndoSteps() const;
const char* msg;
};
-#ifdef ENABLE_XATTRS
struct XAttributesException : public SnapperException
{
- explicit XAttributesException() throw() {}
- virtual const char* what() const throw() { return "XAttributes error"; }
+ explicit XAttributesException() throw() {}
+ virtual const char* what() const throw() { return "XAttributes error"; }
};
-#endif
+
}
*/
+#include "config.h"
+
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <fcntl.h>
#include <boost/algorithm/string.hpp>
-#include "config.h"
#include "snapper/File.h"
#include "snapper/Snapper.h"
#include "snapper/AppUtil.h"
#include "snapper/SnapperDefines.h"
#include "snapper/Compare.h"
#include "snapper/Exception.h"
+#include "snapper/XAttributes.h"
-#ifdef ENABLE_XATTRS
-#include <snapper/XAttributes.h>
-#endif
namespace snapper
{
return true;
}
-#ifdef ENABLE_XATTRS
+
bool
File::modifyXattributes()
{
return xs;
}
-#endif
+
bool
File::doUndo()
error = true;
}
#endif
+
pre_to_system_status = (unsigned int) -1;
post_to_system_status = (unsigned int) -1;
#ifndef SNAPPER_FILE_H
#define SNAPPER_FILE_H
-#include "config.h"
+
#include <sys/stat.h>
#include <string>
friend std::ostream& operator<<(std::ostream& s, const UndoStatistic& rs);
};
-#ifdef ENABLE_XATTRS
+
struct XAUndoStatistic
{
XAUndoStatistic(): numCreate(0), numReplace(0), numDelete(0) {}
friend XAUndoStatistic& operator+=(XAUndoStatistic&, const XAUndoStatistic&);
};
-#endif
struct UndoStep
File(const FilePaths* file_paths, const string& name, unsigned int pre_to_post_status)
: file_paths(file_paths), name(name), pre_to_post_status(pre_to_post_status),
- pre_to_system_status(-1), post_to_system_status(-1), undo(false)
-#ifdef ENABLE_XATTRS
- ,xaCreated(0), xaDeleted(0), xaReplaced(0)
-#endif
+ pre_to_system_status(-1), post_to_system_status(-1), undo(false),
+ xaCreated(0), xaDeleted(0), xaReplaced(0)
{}
const string& getName() const { return name; }
friend std::ostream& operator<<(std::ostream& s, const File& file);
-#ifdef ENABLE_XATTRS
- XAUndoStatistic getXAUndoStatistic() const;
-#endif
+ XAUndoStatistic getXAUndoStatistic() const;
+
private:
bool createParentDirectories(const string& path) const;
bool undo;
-#ifdef ENABLE_XATTRS
- bool modifyXattributes();
+ bool modifyXattributes();
+
+ unsigned int xaCreated;
+ unsigned int xaDeleted;
+ unsigned int xaReplaced;
- unsigned int xaCreated;
- unsigned int xaDeleted;
- unsigned int xaReplaced;
-#endif
};
vector<UndoStep> getUndoSteps() const;
bool doUndoStep(const UndoStep& undo_step);
-#ifdef ENABLE_XATTRS
+
XAUndoStatistic getXAUndoStatistic() const;
-#endif
+
protected:
void push_back(File file) { entries.push_back(file); }
*/
+#include "config.h"
+
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mount.h>
+#include <sys/xattr.h>
#include <fcntl.h>
#include <stddef.h>
#include <dirent.h>
#include <assert.h>
#include <algorithm>
-#include "config.h"
-#ifdef ENABLE_XATTRS
- #include <sys/xattr.h>
-#endif
#include "snapper/FileUtils.h"
#include "snapper/AppUtil.h"
#include "snapper/Log.h"
throw IOErrorException();
}
-#ifdef ENABLE_XATTRS
setXaStatus();
-#endif
}
throw IOErrorException();
}
-#ifdef ENABLE_XATTRS
xastatus = dir.xastatus;
-#endif
}
throw IOErrorException();
}
-#ifdef ENABLE_XATTRS
xastatus = dir.xastatus;
-#endif
}
throw IOErrorException();
}
-#ifdef ENABLE_XATTRS
xastatus = dir.xastatus;
-#endif
}
return *this;
}
-#ifdef ENABLE_XATTRS
-
bool
SDir::xaSupported() const
{
{
xastatus = XA_UNKNOWN;
+#ifdef ENABLE_XATTRS
ssize_t ret = flistxattr(dirfd, NULL, 0);
if (ret < 0)
{
{
xastatus = XA_SUPPORTED;
}
- }
-
#endif
+ }
bool
}
-#ifdef ENABLE_XATTRS
-
bool
SFile::xaSupported() const
{
return dir.getxattr(SFile::name, name, value, size);
}
-#endif
-
}
#ifndef SNAPPER_FILE_UTILS_H
#define SNAPPER_FILE_UTILS_H
-#include "config.h"
#include <string>
#include <vector>
using std::string;
using std::vector;
-#ifdef ENABLE_XATTRS
+
enum XaAttrsStatus {
XA_UNKNOWN,
XA_UNSUPPORTED,
XA_SUPPORTED
};
-#endif
/*
int mktemp(string& name) const;
-#ifdef ENABLE_XATTRS
bool xaSupported() const;
ssize_t listxattr(const string& path, char* list, size_t size) const;
ssize_t getxattr(const string& path, const char* name, void* value, size_t size) const;
-#endif
bool mount(const string& device, const string& mount_type, unsigned long mount_flags,
const string& mount_data) const;
private:
-#ifdef ENABLE_XATTRS
XaAttrsStatus xastatus;
void setXaStatus();
-#endif
const string base_path;
const string path;
int open(int flags) const;
int readlink(string& buf) const;
-#ifdef ENABLE_XATTRS
bool xaSupported() const;
ssize_t listxattr(char* list, size_t size) const;
ssize_t getxattr(const char* name, void* value, size_t size) const;
-#endif
private:
lib_LTLIBRARIES = libsnapper.la
-if HAVE_XATTRS
-TMP_XA = XAttributes.cc XAttributes.h
-endif
-
libsnapper_la_SOURCES = \
Factory.cc Factory.h \
Snapper.cc Snapper.h \
Enum.cc Enum.h \
AppUtil.cc AppUtil.h \
FileUtils.cc FileUtils.h \
+ XAttributes.cc XAttributes.h \
Log.cc Log.h \
Logger.cc Logger.h \
Compare.cc Compare.h \
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
-
#include <iomanip>
+#include <boost/scoped_array.hpp>
#include "snapper/AppUtil.h"
#include "snapper/Exception.h"
#include "snapper/Log.h"
#include "snapper/XAttributes.h"
-#include <boost/scoped_array.hpp>
-
namespace snapper
{
#include <stdint.h>
-
#include <map>
#include <vector>
#include <string>