summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/backupstore/BackupClientFileAttributes.cpp46
-rw-r--r--lib/backupstore/BackupClientFileAttributes.h17
-rw-r--r--lib/backupstore/BackupStoreFile.cpp2
-rw-r--r--lib/backupstore/BackupStoreFile.h4
-rw-r--r--lib/backupstore/BackupStoreFileDiff.cpp4
-rw-r--r--lib/backupstore/BackupStoreFileEncodeStream.cpp2
-rw-r--r--lib/backupstore/BackupStoreFileEncodeStream.h2
7 files changed, 43 insertions, 34 deletions
diff --git a/lib/backupstore/BackupClientFileAttributes.cpp b/lib/backupstore/BackupClientFileAttributes.cpp
index 75d961c4..d76432ba 100644
--- a/lib/backupstore/BackupClientFileAttributes.cpp
+++ b/lib/backupstore/BackupClientFileAttributes.cpp
@@ -364,7 +364,7 @@ bool BackupClientFileAttributes::Compare(const BackupClientFileAttributes &rAttr
// Created: 2003/10/07
//
// --------------------------------------------------------------------------
-void BackupClientFileAttributes::ReadAttributes(const char *Filename,
+void BackupClientFileAttributes::ReadAttributes(const std::string& Filename,
bool ZeroModificationTimes, box_time_t *pModTime,
box_time_t *pAttrModTime, int64_t *pFileSize,
InodeRefType *pInodeNumber, bool *pHasMultipleLinks)
@@ -373,7 +373,7 @@ void BackupClientFileAttributes::ReadAttributes(const char *Filename,
try
{
EMU_STRUCT_STAT st;
- if(EMU_LSTAT(Filename, &st) != 0)
+ if(EMU_LSTAT(Filename.c_str(), &st) != 0)
{
THROW_SYS_FILE_ERROR("Failed to stat file",
Filename, CommonException, OSFileError)
@@ -465,7 +465,7 @@ void BackupClientFileAttributes::ReadAttributes(const char *Filename,
//
// --------------------------------------------------------------------------
void BackupClientFileAttributes::FillAttributes(
- StreamableMemBlock &outputBlock, const char *Filename,
+ StreamableMemBlock &outputBlock, const std::string& rFilename,
const EMU_STRUCT_STAT &st, bool ZeroModificationTimes
)
{
@@ -508,14 +508,16 @@ void BackupClientFileAttributes::FillAttributes(
// Created: 2003/10/07
//
// --------------------------------------------------------------------------
-void BackupClientFileAttributes::FillAttributesLink(StreamableMemBlock &outputBlock, const char *Filename, struct stat &st)
+void BackupClientFileAttributes::FillAttributesLink(
+ StreamableMemBlock &outputBlock, const std::string& Filename,
+ struct stat &st)
{
// Make sure we're only called for symbolic links
ASSERT((st.st_mode & S_IFMT) == S_IFLNK);
// Get the filename the link is linked to
char linkedTo[PATH_MAX+4];
- int linkedToSize = ::readlink(Filename, linkedTo, PATH_MAX);
+ int linkedToSize = ::readlink(Filename.c_str(), linkedTo, PATH_MAX);
if(linkedToSize == -1)
{
BOX_LOG_SYS_ERROR("Failed to readlink '" << Filename << "'");
@@ -540,7 +542,8 @@ void BackupClientFileAttributes::FillAttributesLink(StreamableMemBlock &outputBl
// Created: 2005/06/12
//
// --------------------------------------------------------------------------
-void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBlock, const char *Filename)
+void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBlock,
+ const std::string& Filename)
{
#ifdef HAVE_SYS_XATTR_H
int listBufferSize = 10000;
@@ -550,13 +553,13 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc
{
// This returns an unordered list of attribute names, each 0 terminated,
// concatenated together
- int listSize = ::llistxattr(Filename, list, listBufferSize);
+ int listSize = ::llistxattr(Filename.c_str(), list, listBufferSize);
if(listSize>listBufferSize)
{
delete[] list, list = NULL;
list = new char[listSize];
- listSize = ::llistxattr(Filename, list, listSize);
+ listSize = ::llistxattr(Filename.c_str(), list, listSize);
}
if(listSize>0)
@@ -606,7 +609,7 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc
// Find size of attribute (must call with buffer and length 0 on some platforms,
// as -1 is returned if the data doesn't fit.)
- int valueSize = ::lgetxattr(Filename, attrKey.c_str(), 0, 0);
+ int valueSize = ::lgetxattr(Filename.c_str(), attrKey.c_str(), 0, 0);
if(valueSize<0)
{
BOX_LOG_SYS_ERROR("Failed to get "
@@ -625,7 +628,9 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc
}
// This gets the attribute value (may be text or binary), no termination
- valueSize = ::lgetxattr(Filename, attrKey.c_str(), buffer+xattrSize, xattrBufferSize-xattrSize);
+ valueSize = ::lgetxattr(Filename.c_str(),
+ attrKey.c_str(), buffer+xattrSize,
+ xattrBufferSize-xattrSize);
if(valueSize<0)
{
BOX_LOG_SYS_ERROR("Failed to get "
@@ -742,7 +747,7 @@ void BackupClientFileAttributes::GetModificationTimes(
// Created: 2003/10/07
//
// --------------------------------------------------------------------------
-void BackupClientFileAttributes::WriteAttributes(const char *Filename,
+void BackupClientFileAttributes::WriteAttributes(const std::string& Filename,
bool MakeUserWritable) const
{
// Got something loaded
@@ -795,8 +800,8 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename,
Filename << "'");
#else
// Make a symlink, first deleting anything in the way
- ::unlink(Filename);
- if(::symlink((char*)(pattr + 1), Filename) != 0)
+ ::unlink(Filename.c_str());
+ if(::symlink((char*)(pattr + 1), Filename.c_str()) != 0)
{
BOX_LOG_SYS_ERROR("Failed to symlink '" << Filename <<
"' to '" << (char*)(pattr + 1) << "'");
@@ -815,7 +820,7 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename,
if((mode & S_IFMT) != S_IFLNK)
{
// Not a link, use normal chown
- if(::chown(Filename, ntohl(pattr->UID), ntohl(pattr->GID)) != 0)
+ if(::chown(Filename.c_str(), ntohl(pattr->UID), ntohl(pattr->GID)) != 0)
{
BOX_LOG_SYS_ERROR("Failed to change "
"owner of file "
@@ -825,7 +830,7 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename,
}
#else
// use the version which sets things on symlinks
- if(::lchown(Filename, ntohl(pattr->UID), ntohl(pattr->GID)) != 0)
+ if(::lchown(Filename.c_str(), ntohl(pattr->UID), ntohl(pattr->GID)) != 0)
{
BOX_LOG_SYS_ERROR("Failed to change owner of "
"symbolic link '" << Filename << "'");
@@ -871,7 +876,7 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename,
#endif
// Try to apply
- if(::utimes(Filename, times) != 0)
+ if(::utimes(Filename.c_str(), times) != 0)
{
BOX_LOG_SYS_WARNING("Failed to change times of "
"file '" << Filename << "' to ctime=" <<
@@ -887,8 +892,8 @@ void BackupClientFileAttributes::WriteAttributes(const char *Filename,
// Apply everything else... (allowable mode flags only)
// Mode must be done last (think setuid)
- if(::chmod(Filename, mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID
- | S_ISGID | S_ISVTX)) != 0)
+ if(::chmod(Filename.c_str(), mode & (S_IRWXU | S_IRWXG | S_IRWXO |
+ S_ISUID | S_ISGID | S_ISVTX)) != 0)
{
BOX_LOG_SYS_ERROR("Failed to change permissions of file "
"'" << Filename << "'");
@@ -971,7 +976,7 @@ void BackupClientFileAttributes::EnsureClearAvailable() const
// Created: 2005/06/13
//
// --------------------------------------------------------------------------
-void BackupClientFileAttributes::WriteExtendedAttr(const char *Filename, int xattrOffset) const
+void BackupClientFileAttributes::WriteExtendedAttr(const std::string& Filename, int xattrOffset) const
{
#ifdef HAVE_SYS_XATTR_H
const char* buffer = static_cast<char*>(mpClearAttributes->GetBuffer());
@@ -1004,7 +1009,8 @@ void BackupClientFileAttributes::WriteExtendedAttr(const char *Filename, int xat
xattrOffset += sizeof(u_int32_t);
// FIXME: Warn on EOPNOTSUPP
- if(::lsetxattr(Filename, key, buffer+xattrOffset, valueSize, 0)!=0 && errno!=EOPNOTSUPP)
+ if(::lsetxattr(Filename.c_str(), key, buffer+xattrOffset,
+ valueSize, 0)!=0 && errno!=EOPNOTSUPP)
{
BOX_LOG_SYS_ERROR("Failed to set extended attributes "
"on file '" << Filename << "'");
diff --git a/lib/backupstore/BackupClientFileAttributes.h b/lib/backupstore/BackupClientFileAttributes.h
index 8ae7ffc2..662529ec 100644
--- a/lib/backupstore/BackupClientFileAttributes.h
+++ b/lib/backupstore/BackupClientFileAttributes.h
@@ -43,10 +43,10 @@ public:
// Prevent access to base class members accidently
void Set();
- void ReadAttributes(const char *Filename, bool ZeroModificationTimes = false,
+ void ReadAttributes(const std::string& Filename, bool ZeroModificationTimes = false,
box_time_t *pModTime = 0, box_time_t *pAttrModTime = 0, int64_t *pFileSize = 0,
InodeRefType *pInodeNumber = 0, bool *pHasMultipleLinks = 0);
- void WriteAttributes(const char *Filename,
+ void WriteAttributes(const std::string& Filename,
bool MakeUserWritable = false) const;
void GetModificationTimes(box_time_t *pModificationTime,
box_time_t *pAttrModificationTime) const;
@@ -56,15 +56,18 @@ public:
static void SetBlowfishKey(const void *pKey, int KeyLength);
static void SetAttributeHashSecret(const void *pSecret, int SecretLength);
- static uint64_t GenerateAttributeHash(EMU_STRUCT_STAT &st, const std::string &filename, const std::string &leafname);
- static void FillExtendedAttr(StreamableMemBlock &outputBlock, const char *Filename);
+ static uint64_t GenerateAttributeHash(EMU_STRUCT_STAT &st,
+ const std::string& Filename, const std::string &leafname);
+ static void FillExtendedAttr(StreamableMemBlock &outputBlock,
+ const std::string& Filename);
private:
static void FillAttributes(StreamableMemBlock &outputBlock,
- const char *Filename, const EMU_STRUCT_STAT &st,
+ const std::string& Filename, const EMU_STRUCT_STAT &st,
bool ZeroModificationTimes);
- static void FillAttributesLink(StreamableMemBlock &outputBlock, const char *Filename, struct stat &st);
- void WriteExtendedAttr(const char *Filename, int xattrOffset) const;
+ static void FillAttributesLink(StreamableMemBlock &outputBlock,
+ const std::string& Filename, struct stat &st);
+ void WriteExtendedAttr(const std::string& Filename, int xattrOffset) const;
void RemoveClear() const;
void EnsureClearAvailable() const;
diff --git a/lib/backupstore/BackupStoreFile.cpp b/lib/backupstore/BackupStoreFile.cpp
index bd62b7ba..fe25eaee 100644
--- a/lib/backupstore/BackupStoreFile.cpp
+++ b/lib/backupstore/BackupStoreFile.cpp
@@ -74,7 +74,7 @@ BackupStoreFileStats BackupStoreFile::msStats = {0,0,0};
//
// --------------------------------------------------------------------------
std::auto_ptr<IOStream> BackupStoreFile::EncodeFile(
- const char *Filename, int64_t ContainerID,
+ const std::string& Filename, int64_t ContainerID,
const BackupStoreFilename &rStoreFilename,
int64_t *pModificationTime,
ReadLoggingStream::Logger* pLogger,
diff --git a/lib/backupstore/BackupStoreFile.h b/lib/backupstore/BackupStoreFile.h
index 8398429a..e24ff8cb 100644
--- a/lib/backupstore/BackupStoreFile.h
+++ b/lib/backupstore/BackupStoreFile.h
@@ -121,7 +121,7 @@ public:
// Main interface
static std::auto_ptr<IOStream> EncodeFile
(
- const char *Filename,
+ const std::string& Filename,
int64_t ContainerID, const BackupStoreFilename &rStoreFilename,
int64_t *pModificationTime = 0,
ReadLoggingStream::Logger* pLogger = NULL,
@@ -129,7 +129,7 @@ public:
);
static std::auto_ptr<IOStream> EncodeFileDiff
(
- const char *Filename, int64_t ContainerID,
+ const std::string& Filename, int64_t ContainerID,
const BackupStoreFilename &rStoreFilename,
int64_t DiffFromObjectID, IOStream &rDiffFromBlockIndex,
int Timeout,
diff --git a/lib/backupstore/BackupStoreFileDiff.cpp b/lib/backupstore/BackupStoreFileDiff.cpp
index ce38fabd..c8a28b78 100644
--- a/lib/backupstore/BackupStoreFileDiff.cpp
+++ b/lib/backupstore/BackupStoreFileDiff.cpp
@@ -125,7 +125,7 @@ void BackupStoreFile::MoveStreamPositionToBlockIndex(IOStream &rStream)
// --------------------------------------------------------------------------
std::auto_ptr<IOStream> BackupStoreFile::EncodeFileDiff
(
- const char *Filename, int64_t ContainerID,
+ const std::string& Filename, int64_t ContainerID,
const BackupStoreFilename &rStoreFilename, int64_t DiffFromObjectID,
IOStream &rDiffFromBlockIndex, int Timeout, DiffTimer *pDiffTimer,
int64_t *pModificationTime, bool *pIsCompletelyDifferent)
@@ -133,7 +133,7 @@ std::auto_ptr<IOStream> BackupStoreFile::EncodeFileDiff
// Is it a symlink?
{
EMU_STRUCT_STAT st;
- if(EMU_LSTAT(Filename, &st) != 0)
+ if(EMU_LSTAT(Filename.c_str(), &st) != 0)
{
THROW_EXCEPTION(CommonException, OSFileError)
}
diff --git a/lib/backupstore/BackupStoreFileEncodeStream.cpp b/lib/backupstore/BackupStoreFileEncodeStream.cpp
index e9d773f0..b53c4c26 100644
--- a/lib/backupstore/BackupStoreFileEncodeStream.cpp
+++ b/lib/backupstore/BackupStoreFileEncodeStream.cpp
@@ -111,7 +111,7 @@ BackupStoreFileEncodeStream::~BackupStoreFileEncodeStream()
// Created: 8/12/03
//
// --------------------------------------------------------------------------
-void BackupStoreFileEncodeStream::Setup(const char *Filename,
+void BackupStoreFileEncodeStream::Setup(const std::string& Filename,
BackupStoreFileEncodeStream::Recipe *pRecipe,
int64_t ContainerID, const BackupStoreFilename &rStoreFilename,
int64_t *pModificationTime, ReadLoggingStream::Logger* pLogger,
diff --git a/lib/backupstore/BackupStoreFileEncodeStream.h b/lib/backupstore/BackupStoreFileEncodeStream.h
index 023994af..a169e036 100644
--- a/lib/backupstore/BackupStoreFileEncodeStream.h
+++ b/lib/backupstore/BackupStoreFileEncodeStream.h
@@ -75,7 +75,7 @@ public:
int64_t mOtherFileID;
};
- void Setup(const char *Filename, Recipe *pRecipe, int64_t ContainerID,
+ void Setup(const std::string& Filename, Recipe *pRecipe, int64_t ContainerID,
const BackupStoreFilename &rStoreFilename,
int64_t *pModificationTime,
ReadLoggingStream::Logger* pLogger = NULL,