diff options
Diffstat (limited to 'lib/raidfile/RaidFileWrite.cpp')
-rw-r--r-- | lib/raidfile/RaidFileWrite.cpp | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/lib/raidfile/RaidFileWrite.cpp b/lib/raidfile/RaidFileWrite.cpp index cb1f9699..82aeef3d 100644 --- a/lib/raidfile/RaidFileWrite.cpp +++ b/lib/raidfile/RaidFileWrite.cpp @@ -11,12 +11,6 @@ #include <errno.h> #include <fcntl.h> -<<<<<<< HEAD -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <sys/file.h> -======= #ifdef HAVE_UNISTD_H # include <unistd.h> @@ -28,7 +22,6 @@ #ifdef HAVE_SYS_FILE_H # include <sys/file.h> #endif ->>>>>>> 0.12 #include <stdio.h> #include <string.h> @@ -109,9 +102,6 @@ RaidFileWrite::~RaidFileWrite() { if(mOSFileHandle != -1) { -<<<<<<< HEAD - Discard(); -======= // We must not throw exceptions from the destructor // http://stackoverflow.com/a/130123 try @@ -134,7 +124,6 @@ RaidFileWrite::~RaidFileWrite() BOX_ERROR("Failed to discard RaidFile update " "in destructor: unknown exception"); } ->>>>>>> 0.12 } } @@ -165,45 +154,25 @@ void RaidFileWrite::Open(bool AllowOverwrite) RaidFileUtil::ExistType existance = RaidFileUtil::RaidFileExists(rdiscSet, mFilename); if(existance != RaidFileUtil::NoFile) { -<<<<<<< HEAD - BOX_ERROR("Attempted to overwrite raidfile " << - mSetNumber << " " << mFilename); - THROW_EXCEPTION(RaidFileException, CannotOverwriteExistingFile) -======= THROW_FILE_ERROR("Attempted to overwrite raidfile " << mSetNumber, mFilename, RaidFileException, CannotOverwriteExistingFile); ->>>>>>> 0.12 } } // Get the filename for the write file -<<<<<<< HEAD - std::string writeFilename(RaidFileUtil::MakeWriteFileName(rdiscSet, mFilename)); - // Add on a temporary extension - writeFilename += 'X'; - - // Attempt to open - mOSFileHandle = ::open(writeFilename.c_str(), -======= mTempFilename = RaidFileUtil::MakeWriteFileName(rdiscSet, mFilename); // Add on a temporary extension mTempFilename += 'X'; // Attempt to open mOSFileHandle = ::open(mTempFilename.c_str(), ->>>>>>> 0.12 O_WRONLY | O_CREAT | O_BINARY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); if(mOSFileHandle == -1) { -<<<<<<< HEAD - BOX_LOG_SYS_ERROR("Failed to open file: " << writeFilename); - THROW_EXCEPTION(RaidFileException, ErrorOpeningWriteFile) -======= THROW_SYS_FILE_ERROR("Failed to open RaidFile", mTempFilename, RaidFileException, ErrorOpeningWriteFile); ->>>>>>> 0.12 } // Get a lock on the write file @@ -223,17 +192,6 @@ void RaidFileWrite::Open(bool AllowOverwrite) if (0) #endif { -<<<<<<< HEAD - // Lock was not obtained. - bool wasLocked = (errno == errnoBlock); - // Close the file - ::close(mOSFileHandle); - mOSFileHandle = -1; - // Report an exception? - if(wasLocked) - { - THROW_EXCEPTION(RaidFileException, FileIsCurrentlyOpenForWriting) -======= int errnoSaved = errno; // Lock was not obtained. @@ -250,27 +208,19 @@ void RaidFileWrite::Open(bool AllowOverwrite) "already locked", mTempFilename, errnoSaved, RaidFileException, FileIsCurrentlyOpenForWriting); ->>>>>>> 0.12 } else { // Random error occured -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_SYS_FILE_ERRNO("Failed to lock RaidFile", mTempFilename, errnoSaved, RaidFileException, OSError); ->>>>>>> 0.12 } } // Truncate it to size zero if(::ftruncate(mOSFileHandle, 0) != 0) { -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, ErrorOpeningWriteFileOnTruncate) -======= int errnoSaved = errno; // Close the file @@ -280,7 +230,6 @@ void RaidFileWrite::Open(bool AllowOverwrite) THROW_SYS_FILE_ERRNO("Failed to truncate RaidFile", mTempFilename, errnoSaved, RaidFileException, ErrorOpeningWriteFileOnTruncate); ->>>>>>> 0.12 } // Done! @@ -306,16 +255,10 @@ void RaidFileWrite::Write(const void *pBuffer, int Length) int written = ::write(mOSFileHandle, pBuffer, Length); if(written != Length) { -<<<<<<< HEAD - BOX_LOG_SYS_ERROR("RaidFileWrite failed, Length = " << - Length << ", written = " << written); - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_SYS_FILE_ERROR("Failed to write to RaidFile (attempted " "to write " << Length << " bytes but managed only " << written << ")", mTempFilename, RaidFileException, OSError); ->>>>>>> 0.12 } } @@ -339,12 +282,8 @@ IOStream::pos_type RaidFileWrite::GetPosition() const off_t p = ::lseek(mOSFileHandle, 0, SEEK_CUR); if(p == -1) { -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_SYS_FILE_ERROR("Failed to get position in RaidFile", mTempFilename, RaidFileException, OSError); ->>>>>>> 0.12 } return p; @@ -369,12 +308,8 @@ void RaidFileWrite::Seek(IOStream::pos_type SeekTo, int SeekType) // Seek... if(::lseek(mOSFileHandle, SeekTo, ConvertSeekTypeToOSWhence(SeekType)) == -1) { -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_SYS_FILE_ERROR("Failed to set position in RaidFile", mTempFilename, RaidFileException, OSError); ->>>>>>> 0.12 } } @@ -396,14 +331,8 @@ void RaidFileWrite::Commit(bool ConvertToRaidNow) if (mRefCount == 0) { -<<<<<<< HEAD - BOX_ERROR("Attempted to modify object " << mFilename << - ", which has no references"); - THROW_EXCEPTION(RaidFileException, -======= THROW_FILE_ERROR("Attempted to modify object file with " "no references", mTempFilename, RaidFileException, ->>>>>>> 0.12 RequestedModifyUnreferencedFile); } @@ -414,12 +343,8 @@ void RaidFileWrite::Commit(bool ConvertToRaidNow) // Close file... if(::close(mOSFileHandle) != 0) { -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_WIN_FILE_ERROR("Failed to close RaidFile for rename", mTempFilename, RaidFileException, OSError); ->>>>>>> 0.12 } mOSFileHandle = -1; #endif // WIN32 @@ -433,13 +358,6 @@ void RaidFileWrite::Commit(bool ConvertToRaidNow) #ifdef WIN32 // need to delete the target first -<<<<<<< HEAD - if(::unlink(renameTo.c_str()) != 0 && - GetLastError() != ERROR_FILE_NOT_FOUND) - { - BOX_LOG_WIN_ERROR("Failed to delete file: " << renameTo); - THROW_EXCEPTION(RaidFileException, OSError) -======= if(::unlink(renameTo.c_str()) != 0) { DWORD errorNumber = GetLastError(); @@ -448,32 +366,21 @@ void RaidFileWrite::Commit(bool ConvertToRaidNow) THROW_WIN_FILE_ERRNO("Failed to delete file", renameTo, errorNumber, RaidFileException, OSError); } ->>>>>>> 0.12 } #endif if(::rename(renameFrom.c_str(), renameTo.c_str()) != 0) { -<<<<<<< HEAD - BOX_LOG_SYS_ERROR("Failed to rename file: " << renameFrom << - " to " << renameTo); - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_SYS_ERROR("Failed to rename file: " << renameFrom << " to " << renameTo, RaidFileException, OSError); ->>>>>>> 0.12 } #ifndef WIN32 // Close file... if(::close(mOSFileHandle) != 0) { -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_SYS_FILE_ERROR("Failed to close committed RaidFile", mTempFilename, RaidFileException, OSError); ->>>>>>> 0.12 } mOSFileHandle = -1; #endif // !WIN32 @@ -520,13 +427,8 @@ void RaidFileWrite::Discard() ::close(mOSFileHandle) != 0) #endif // !WIN32 { -<<<<<<< HEAD - BOX_LOG_SYS_ERROR("Failed to delete file: " << writeFilename); - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_SYS_FILE_ERROR("Failed to delete file", writeFilename, RaidFileException, OSError); ->>>>>>> 0.12 } // reset file handle @@ -827,16 +729,9 @@ void RaidFileWrite::Delete() { if (mRefCount != 0 && mRefCount != -1) { -<<<<<<< HEAD - BOX_ERROR("Attempted to delete object " << mFilename << - " which has " << mRefCount << " references"); - THROW_EXCEPTION(RaidFileException, - RequestedDeleteReferencedFile); -======= THROW_FILE_ERROR("Attempted to delete object with " << mRefCount << " references", mFilename, RaidFileException, RequestedDeleteReferencedFile); ->>>>>>> 0.12 } // Get disc set @@ -847,13 +742,9 @@ void RaidFileWrite::Delete() RaidFileUtil::ExistType existance = RaidFileUtil::RaidFileExists(rdiscSet, mFilename); if(existance == RaidFileUtil::NoFile) { -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, RaidFileDoesntExist) -======= THROW_FILE_ERROR("Attempted to delete object which doesn't " "exist", mFilename, RaidFileException, RaidFileDoesntExist); ->>>>>>> 0.12 } // Get the filename for the write file @@ -892,12 +783,8 @@ void RaidFileWrite::Delete() // Check something happened if(!deletedSomething) { -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_FILE_ERROR("Failed to delete a RaidFile stripe set", mFilename, RaidFileException, OSError); ->>>>>>> 0.12 } } @@ -968,13 +855,6 @@ void RaidFileWrite::CreateDirectory(const RaidFileDiscSet &rSet, const std::stri if(errno == EEXIST) { // No. Bad things. -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, FileExistsInDirectoryCreation) - } - else - { - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_SYS_FILE_ERROR("Failed to create " "RaidFile directory", dn, RaidFileException, @@ -985,7 +865,6 @@ void RaidFileWrite::CreateDirectory(const RaidFileDiscSet &rSet, const std::stri THROW_SYS_FILE_ERROR("Failed to create " "RaidFile directory", dn, RaidFileException, OSError); ->>>>>>> 0.12 } } } @@ -1068,12 +947,8 @@ IOStream::pos_type RaidFileWrite::GetFileSize() struct stat st; if(fstat(mOSFileHandle, &st) != 0) { -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_SYS_FILE_ERROR("Failed to stat RaidFile", mTempFilename, RaidFileException, OSError); ->>>>>>> 0.12 } return st.st_size; @@ -1102,12 +977,8 @@ IOStream::pos_type RaidFileWrite::GetDiscUsageInBlocks() struct stat st; if(fstat(mOSFileHandle, &st) != 0) { -<<<<<<< HEAD - THROW_EXCEPTION(RaidFileException, OSError) -======= THROW_SYS_FILE_ERROR("Failed to stat RaidFile", mTempFilename, RaidFileException, OSError); ->>>>>>> 0.12 } // Then return calculation |