Use workaround for GCC Bug 66145
This commit is contained in:
parent
b7eef68fc6
commit
cf5b021180
|
@ -4,6 +4,7 @@
|
||||||
#include "./exceptions.h"
|
#include "./exceptions.h"
|
||||||
|
|
||||||
#include <c++utilities/misc/memory.h>
|
#include <c++utilities/misc/memory.h>
|
||||||
|
#include <c++utilities/io/catchiofailure.h>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ StreamDataBlock::StreamDataBlock(const std::function<std::istream & ()> &stream,
|
||||||
m_endOffset = s.tellg();
|
m_endOffset = s.tellg();
|
||||||
s.seekg(currentPos);
|
s.seekg(currentPos);
|
||||||
if(m_endOffset < m_startOffset) {
|
if(m_endOffset < m_startOffset) {
|
||||||
throw ios_base::failure("End offset is less then start offset.");
|
IoUtilities::throwIoFailure("End offset is less then start offset.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <c++utilities/io/binaryreader.h>
|
#include <c++utilities/io/binaryreader.h>
|
||||||
#include <c++utilities/io/bitreader.h>
|
#include <c++utilities/io/bitreader.h>
|
||||||
#include <c++utilities/misc/memory.h>
|
#include <c++utilities/misc/memory.h>
|
||||||
|
#include <c++utilities/io/catchiofailure.h>
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
@ -200,7 +201,8 @@ void SpsInfo::parse(BinaryReader &reader, uint32 maxSize)
|
||||||
pictureSize.setWidth(mbSize.width() * 16);
|
pictureSize.setWidth(mbSize.width() * 16);
|
||||||
pictureSize.setHeight((2 - frameMbsOnly) * mbSize.height() * 16);
|
pictureSize.setHeight((2 - frameMbsOnly) * mbSize.height() * 16);
|
||||||
}
|
}
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
catchIoFailure();
|
||||||
throw TruncatedDataException();
|
throw TruncatedDataException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,7 +241,8 @@ void PpsInfo::parse(BinaryReader &reader, uint32 maxSize)
|
||||||
spsId = bitReader.readUnsignedExpGolombCodedBits<ugolomb>();
|
spsId = bitReader.readUnsignedExpGolombCodedBits<ugolomb>();
|
||||||
bitReader.skipBits(1); // entropy coding mode flag
|
bitReader.skipBits(1); // entropy coding mode flag
|
||||||
picOrderPresent = bitReader.readBit();
|
picOrderPresent = bitReader.readBit();
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
catchIoFailure();
|
||||||
throw TruncatedDataException();
|
throw TruncatedDataException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "./mediafileinfo.h"
|
#include "./mediafileinfo.h"
|
||||||
|
|
||||||
#include <c++utilities/conversion/stringconversion.h>
|
#include <c++utilities/conversion/stringconversion.h>
|
||||||
|
#include <c++utilities/io/catchiofailure.h>
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
#ifdef PLATFORM_WINDOWS
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ConversionUtilities;
|
using namespace ConversionUtilities;
|
||||||
|
using namespace IoUtilities;
|
||||||
|
|
||||||
namespace Media {
|
namespace Media {
|
||||||
|
|
||||||
|
@ -72,7 +74,7 @@ void restoreOriginalFileFromBackupFile(const std::string &originalPath, const st
|
||||||
if(backupStream.is_open()) {
|
if(backupStream.is_open()) {
|
||||||
backupStream.close();
|
backupStream.close();
|
||||||
} else {
|
} else {
|
||||||
throw ios_base::failure("Backup/temporary file has not been created.");
|
throwIoFailure("Backup/temporary file has not been created.");
|
||||||
}
|
}
|
||||||
// remove original file and restore backup
|
// remove original file and restore backup
|
||||||
std::remove(originalPath.c_str());
|
std::remove(originalPath.c_str());
|
||||||
|
@ -86,8 +88,9 @@ void restoreOriginalFileFromBackupFile(const std::string &originalPath, const st
|
||||||
originalStream.open(originalPath, ios_base::out | ios_base::binary);
|
originalStream.open(originalPath, ios_base::out | ios_base::binary);
|
||||||
originalStream << backupStream.rdbuf();
|
originalStream << backupStream.rdbuf();
|
||||||
// TODO: callback for progress updates
|
// TODO: callback for progress updates
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
throw ios_base::failure("Unable to restore original file from backup file \"" + backupPath + "\" after failure.");
|
catchIoFailure();
|
||||||
|
throwIoFailure(("Unable to restore original file from backup file \"" + backupPath + "\" after failure.").data());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,8 +204,9 @@ void createBackupFile(const std::string &originalPath, std::string &backupPath,
|
||||||
backupStream << originalStream.rdbuf();
|
backupStream << originalStream.rdbuf();
|
||||||
// streams are closed in the next try-block
|
// streams are closed in the next try-block
|
||||||
// TODO: callback for progress updates
|
// TODO: callback for progress updates
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
throw ios_base::failure("Unable to rename original file before rewriting it.");
|
catchIoFailure();
|
||||||
|
throwIoFailure("Unable to rename original file before rewriting it.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -217,13 +221,14 @@ void createBackupFile(const std::string &originalPath, std::string &backupPath,
|
||||||
// open backup stream
|
// open backup stream
|
||||||
backupStream.exceptions(ios_base::failbit | ios_base::badbit);
|
backupStream.exceptions(ios_base::failbit | ios_base::badbit);
|
||||||
backupStream.open(backupPath, ios_base::in | ios_base::binary);
|
backupStream.open(backupPath, ios_base::in | ios_base::binary);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
catchIoFailure();
|
||||||
// can't open the new file
|
// can't open the new file
|
||||||
// -> try to re-rename backup file in the error case to restore previous state
|
// -> try to re-rename backup file in the error case to restore previous state
|
||||||
if(std::rename(backupPath.c_str(), originalPath.c_str()) != 0) {
|
if(std::rename(backupPath.c_str(), originalPath.c_str()) != 0) {
|
||||||
throw ios_base::failure("Unable to restore original file from backup file \"" + backupPath + "\" after failure.");
|
throwIoFailure(("Unable to restore original file from backup file \"" + backupPath + "\" after failure.").data());
|
||||||
} else {
|
} else {
|
||||||
throw ios_base::failure("Unable to open backup file.");
|
throwIoFailure("Unable to open backup file.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,8 +268,8 @@ void handleFailureAfterFileModified(MediaFileInfo &fileInfo, const std::string &
|
||||||
try {
|
try {
|
||||||
restoreOriginalFileFromBackupFile(fileInfo.path(), backupPath, outputStream, backupStream);
|
restoreOriginalFileFromBackupFile(fileInfo.path(), backupPath, outputStream, backupStream);
|
||||||
fileInfo.addNotification(NotificationType::Information, "The original file has been restored.", context);
|
fileInfo.addNotification(NotificationType::Information, "The original file has been restored.", context);
|
||||||
} catch(const ios_base::failure &ex) {
|
} catch(...) {
|
||||||
fileInfo.addNotification(NotificationType::Critical, ex.what(), context);
|
fileInfo.addNotification(NotificationType::Critical, catchIoFailure(), context);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileInfo.addNotification(NotificationType::Information, "Applying new tag information has been aborted.", context);
|
fileInfo.addNotification(NotificationType::Information, "Applying new tag information has been aborted.", context);
|
||||||
|
@ -278,29 +283,29 @@ void handleFailureAfterFileModified(MediaFileInfo &fileInfo, const std::string &
|
||||||
try {
|
try {
|
||||||
restoreOriginalFileFromBackupFile(fileInfo.path(), backupPath, outputStream, backupStream);
|
restoreOriginalFileFromBackupFile(fileInfo.path(), backupPath, outputStream, backupStream);
|
||||||
fileInfo.addNotification(NotificationType::Information, "The original file has been restored.", context);
|
fileInfo.addNotification(NotificationType::Information, "The original file has been restored.", context);
|
||||||
} catch(const ios_base::failure &ex) {
|
} catch(...) {
|
||||||
fileInfo.addNotification(NotificationType::Critical, ex.what(), context);
|
fileInfo.addNotification(NotificationType::Critical, catchIoFailure(), context);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileInfo.addNotification(NotificationType::Critical, "Applying new tag information failed.", context);
|
fileInfo.addNotification(NotificationType::Critical, "Applying new tag information failed.", context);
|
||||||
}
|
}
|
||||||
throw;
|
throw;
|
||||||
|
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
if(!backupPath.empty()) {
|
if(!backupPath.empty()) {
|
||||||
// a temp/backup file has been created -> restore original file
|
// a temp/backup file has been created -> restore original file
|
||||||
fileInfo.addNotification(NotificationType::Critical, "An IO error occured when rewriting the file to apply changed tag information.", context);
|
fileInfo.addNotification(NotificationType::Critical, "An IO error occured when rewriting the file to apply changed tag information.", context);
|
||||||
try {
|
try {
|
||||||
restoreOriginalFileFromBackupFile(fileInfo.path(), backupPath, outputStream, backupStream);
|
restoreOriginalFileFromBackupFile(fileInfo.path(), backupPath, outputStream, backupStream);
|
||||||
fileInfo.addNotification(NotificationType::Information, "The original file has been restored.", context);
|
fileInfo.addNotification(NotificationType::Information, "The original file has been restored.", context);
|
||||||
} catch(const ios_base::failure &ex) {
|
} catch(...) {
|
||||||
fileInfo.addNotification(NotificationType::Critical, ex.what(), context);
|
fileInfo.addNotification(NotificationType::Critical, catchIoFailure(), context);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileInfo.addNotification(NotificationType::Critical, "An IO error occured when applying tag information.", context);
|
fileInfo.addNotification(NotificationType::Critical, "An IO error occured when applying tag information.", context);
|
||||||
}
|
}
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "resources/config.h"
|
#include "resources/config.h"
|
||||||
|
|
||||||
#include <c++utilities/conversion/stringconversion.h>
|
#include <c++utilities/conversion/stringconversion.h>
|
||||||
|
#include <c++utilities/io/catchiofailure.h>
|
||||||
#include <c++utilities/misc/memory.h>
|
#include <c++utilities/misc/memory.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -1319,9 +1320,10 @@ nonRewriteCalculations:
|
||||||
} catch(const Failure &) {
|
} catch(const Failure &) {
|
||||||
addNotification(NotificationType::Critical, "Parsing the original file failed.", context);
|
addNotification(NotificationType::Critical, "Parsing the original file failed.", context);
|
||||||
throw;
|
throw;
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "An IO error occured when parsing the original file.", context);
|
addNotification(NotificationType::Critical, "An IO error occured when parsing the original file.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isAborted()) {
|
if(isAborted()) {
|
||||||
|
@ -1346,9 +1348,10 @@ nonRewriteCalculations:
|
||||||
BackupHelper::createBackupFile(fileInfo().path(), backupPath, outputStream, backupStream);
|
BackupHelper::createBackupFile(fileInfo().path(), backupPath, outputStream, backupStream);
|
||||||
// recreate original file, define buffer variables
|
// recreate original file, define buffer variables
|
||||||
outputStream.open(fileInfo().path(), ios_base::out | ios_base::binary | ios_base::trunc);
|
outputStream.open(fileInfo().path(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Creation of temporary file (to rewrite the original file) failed.", context);
|
addNotification(NotificationType::Critical, "Creation of temporary file (to rewrite the original file) failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// open the current file as backupStream and create a new outputStream at the specified "save file path"
|
// open the current file as backupStream and create a new outputStream at the specified "save file path"
|
||||||
|
@ -1357,9 +1360,10 @@ nonRewriteCalculations:
|
||||||
backupStream.open(fileInfo().path(), ios_base::in | ios_base::binary);
|
backupStream.open(fileInfo().path(), ios_base::in | ios_base::binary);
|
||||||
fileInfo().close();
|
fileInfo().close();
|
||||||
outputStream.open(fileInfo().saveFilePath(), ios_base::out | ios_base::binary | ios_base::trunc);
|
outputStream.open(fileInfo().saveFilePath(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Opening streams to write output file failed.", context);
|
addNotification(NotificationType::Critical, "Opening streams to write output file failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1378,9 +1382,10 @@ nonRewriteCalculations:
|
||||||
try {
|
try {
|
||||||
fileInfo().close();
|
fileInfo().close();
|
||||||
outputStream.open(fileInfo().path(), ios_base::in | ios_base::out | ios_base::binary);
|
outputStream.open(fileInfo().path(), ios_base::in | ios_base::out | ios_base::binary);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Opening the file with write permissions failed.", context);
|
addNotification(NotificationType::Critical, "Opening the file with write permissions failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "./flac/flacmetadata.h"
|
#include "./flac/flacmetadata.h"
|
||||||
|
|
||||||
#include <c++utilities/conversion/stringconversion.h>
|
#include <c++utilities/conversion/stringconversion.h>
|
||||||
|
#include <c++utilities/io/catchiofailure.h>
|
||||||
#include <c++utilities/chrono/timespan.h>
|
#include <c++utilities/chrono/timespan.h>
|
||||||
#include <c++utilities/misc/memory.h>
|
#include <c++utilities/misc/memory.h>
|
||||||
|
|
||||||
|
@ -1507,7 +1508,7 @@ void MediaFileInfo::makeMp3File()
|
||||||
reportSizeChanged(size() - 128);
|
reportSizeChanged(size() - 128);
|
||||||
} else {
|
} else {
|
||||||
addNotification(NotificationType::Critical, "Unable to truncate file to remove ID3v1 tag.", context);
|
addNotification(NotificationType::Critical, "Unable to truncate file to remove ID3v1 tag.", context);
|
||||||
throw ios_base::failure("Unable to truncate file to remove ID3v1 tag.");
|
throwIoFailure("Unable to truncate file to remove ID3v1 tag.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1613,9 +1614,10 @@ void MediaFileInfo::makeMp3File()
|
||||||
BackupHelper::createBackupFile(path(), backupPath, outputStream, backupStream);
|
BackupHelper::createBackupFile(path(), backupPath, outputStream, backupStream);
|
||||||
// recreate original file, define buffer variables
|
// recreate original file, define buffer variables
|
||||||
outputStream.open(path(), ios_base::out | ios_base::binary | ios_base::trunc);
|
outputStream.open(path(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Creation of temporary file (to rewrite the original file) failed.", context);
|
addNotification(NotificationType::Critical, "Creation of temporary file (to rewrite the original file) failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// open the current file as backupStream and create a new outputStream at the specified "save file path"
|
// open the current file as backupStream and create a new outputStream at the specified "save file path"
|
||||||
|
@ -1623,9 +1625,10 @@ void MediaFileInfo::makeMp3File()
|
||||||
backupStream.exceptions(ios_base::badbit | ios_base::failbit);
|
backupStream.exceptions(ios_base::badbit | ios_base::failbit);
|
||||||
backupStream.open(path(), ios_base::in | ios_base::binary);
|
backupStream.open(path(), ios_base::in | ios_base::binary);
|
||||||
outputStream.open(m_saveFilePath, ios_base::out | ios_base::binary | ios_base::trunc);
|
outputStream.open(m_saveFilePath, ios_base::out | ios_base::binary | ios_base::trunc);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Opening streams to write output file failed.", context);
|
addNotification(NotificationType::Critical, "Opening streams to write output file failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1634,9 +1637,10 @@ void MediaFileInfo::makeMp3File()
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
outputStream.open(path(), ios_base::in | ios_base::out | ios_base::binary);
|
outputStream.open(path(), ios_base::in | ios_base::out | ios_base::binary);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Opening the file with write permissions failed.", context);
|
addNotification(NotificationType::Critical, "Opening the file with write permissions failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <c++utilities/io/binaryreader.h>
|
#include <c++utilities/io/binaryreader.h>
|
||||||
#include <c++utilities/io/binarywriter.h>
|
#include <c++utilities/io/binarywriter.h>
|
||||||
#include <c++utilities/io/copy.h>
|
#include <c++utilities/io/copy.h>
|
||||||
|
#include <c++utilities/io/catchiofailure.h>
|
||||||
#include <c++utilities/misc/memory.h>
|
#include <c++utilities/misc/memory.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -498,9 +499,10 @@ calculatePadding:
|
||||||
BackupHelper::createBackupFile(fileInfo().path(), backupPath, outputStream, backupStream);
|
BackupHelper::createBackupFile(fileInfo().path(), backupPath, outputStream, backupStream);
|
||||||
// recreate original file, define buffer variables
|
// recreate original file, define buffer variables
|
||||||
outputStream.open(fileInfo().path(), ios_base::out | ios_base::binary | ios_base::trunc);
|
outputStream.open(fileInfo().path(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Creation of temporary file (to rewrite the original file) failed.", context);
|
addNotification(NotificationType::Critical, "Creation of temporary file (to rewrite the original file) failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// open the current file as backupStream and create a new outputStream at the specified "save file path"
|
// open the current file as backupStream and create a new outputStream at the specified "save file path"
|
||||||
|
@ -509,9 +511,10 @@ calculatePadding:
|
||||||
backupStream.open(fileInfo().path(), ios_base::in | ios_base::binary);
|
backupStream.open(fileInfo().path(), ios_base::in | ios_base::binary);
|
||||||
fileInfo().close();
|
fileInfo().close();
|
||||||
outputStream.open(fileInfo().saveFilePath(), ios_base::out | ios_base::binary | ios_base::trunc);
|
outputStream.open(fileInfo().saveFilePath(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Opening streams to write output file failed.", context);
|
addNotification(NotificationType::Critical, "Opening streams to write output file failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,9 +528,10 @@ calculatePadding:
|
||||||
try {
|
try {
|
||||||
fileInfo().close();
|
fileInfo().close();
|
||||||
outputStream.open(fileInfo().path(), ios_base::in | ios_base::out | ios_base::binary);
|
outputStream.open(fileInfo().path(), ios_base::in | ios_base::out | ios_base::binary);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Opening the file with write permissions failed.", context);
|
addNotification(NotificationType::Critical, "Opening the file with write permissions failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <c++utilities/io/binaryreader.h>
|
#include <c++utilities/io/binaryreader.h>
|
||||||
#include <c++utilities/io/binarywriter.h>
|
#include <c++utilities/io/binarywriter.h>
|
||||||
#include <c++utilities/io/bitreader.h>
|
#include <c++utilities/io/bitreader.h>
|
||||||
|
#include <c++utilities/io/catchiofailure.h>
|
||||||
|
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
@ -645,16 +646,17 @@ unique_ptr<Mpeg4AudioSpecificConfig> Mp4Track::parseAudioSpecificConfig(StatusPr
|
||||||
audioCfg->psPresent = bitReader.readBit();
|
audioCfg->psPresent = bitReader.readBit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(ios_base::failure &) {
|
} catch(const NotImplementedException &) {
|
||||||
|
statusProvider.addNotification(NotificationType::Information, "Not implemented for the format of audio track.", context);
|
||||||
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
if(stream.fail()) {
|
if(stream.fail()) {
|
||||||
// IO error caused by input stream
|
// IO error caused by input stream
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
} else {
|
} else {
|
||||||
// IO error caused by bitReader
|
// IO error caused by bitReader
|
||||||
statusProvider.addNotification(NotificationType::Critical, "Audio specific configuration is truncated.", context);
|
statusProvider.addNotification(NotificationType::Critical, "Audio specific configuration is truncated.", context);
|
||||||
}
|
}
|
||||||
} catch(NotImplementedException &) {
|
|
||||||
statusProvider.addNotification(NotificationType::Information, "Not implemented for the format of audio track.", context);
|
|
||||||
}
|
}
|
||||||
return audioCfg;
|
return audioCfg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "../backuphelper.h"
|
#include "../backuphelper.h"
|
||||||
|
|
||||||
#include <c++utilities/io/copy.h>
|
#include <c++utilities/io/copy.h>
|
||||||
|
#include <c++utilities/io/catchiofailure.h>
|
||||||
#include <c++utilities/misc/memory.h>
|
#include <c++utilities/misc/memory.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -338,9 +339,10 @@ void OggContainer::internalMakeFile()
|
||||||
BackupHelper::createBackupFile(fileInfo().path(), backupPath, fileInfo().stream(), backupStream);
|
BackupHelper::createBackupFile(fileInfo().path(), backupPath, fileInfo().stream(), backupStream);
|
||||||
// recreate original file, define buffer variables
|
// recreate original file, define buffer variables
|
||||||
fileInfo().stream().open(fileInfo().path(), ios_base::out | ios_base::binary | ios_base::trunc);
|
fileInfo().stream().open(fileInfo().path(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Creation of temporary file (to rewrite the original file) failed.", context);
|
addNotification(NotificationType::Critical, "Creation of temporary file (to rewrite the original file) failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// open the current file as backupStream and create a new outputStream at the specified "save file path"
|
// open the current file as backupStream and create a new outputStream at the specified "save file path"
|
||||||
|
@ -349,9 +351,10 @@ void OggContainer::internalMakeFile()
|
||||||
backupStream.open(fileInfo().path(), ios_base::in | ios_base::binary);
|
backupStream.open(fileInfo().path(), ios_base::in | ios_base::binary);
|
||||||
fileInfo().close();
|
fileInfo().close();
|
||||||
fileInfo().stream().open(fileInfo().saveFilePath(), ios_base::out | ios_base::binary | ios_base::trunc);
|
fileInfo().stream().open(fileInfo().saveFilePath(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||||
} catch(const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
const char *what = catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "Opening streams to write output file failed.", context);
|
addNotification(NotificationType::Critical, "Opening streams to write output file failed.", context);
|
||||||
throw;
|
throwIoFailure(what);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include <c++utilities/io/binaryreader.h>
|
#include <c++utilities/io/binaryreader.h>
|
||||||
#include <c++utilities/io/binarywriter.h>
|
#include <c++utilities/io/binarywriter.h>
|
||||||
|
#include <c++utilities/io/catchiofailure.h>
|
||||||
#include <c++utilities/conversion/binaryconversion.h>
|
#include <c++utilities/conversion/binaryconversion.h>
|
||||||
#include <c++utilities/conversion/stringconversion.h>
|
#include <c++utilities/conversion/stringconversion.h>
|
||||||
#include <c++utilities/misc/memory.h>
|
#include <c++utilities/misc/memory.h>
|
||||||
|
@ -80,15 +81,16 @@ void VorbisCommentField::internalParse(StreamType &stream, uint64 &maxSize)
|
||||||
FlacMetaDataBlockPicture pictureBlock(value());
|
FlacMetaDataBlockPicture pictureBlock(value());
|
||||||
pictureBlock.parse(bufferStream, decoded.second);
|
pictureBlock.parse(bufferStream, decoded.second);
|
||||||
setTypeInfo(pictureBlock.pictureType());
|
setTypeInfo(pictureBlock.pictureType());
|
||||||
} catch(const ios_base::failure &) {
|
|
||||||
addNotification(NotificationType::Critical, "An IO error occured when reading the METADATA_BLOCK_PICTURE struct.", context);
|
|
||||||
throw Failure();
|
|
||||||
} catch(const TruncatedDataException &) {
|
} catch(const TruncatedDataException &) {
|
||||||
addNotification(NotificationType::Critical, "METADATA_BLOCK_PICTURE is truncated.", context);
|
addNotification(NotificationType::Critical, "METADATA_BLOCK_PICTURE is truncated.", context);
|
||||||
throw;
|
throw;
|
||||||
} catch(const ConversionException &) {
|
} catch(const ConversionException &) {
|
||||||
addNotification(NotificationType::Critical, "Base64 coding of METADATA_BLOCK_PICTURE is invalid.", context);
|
addNotification(NotificationType::Critical, "Base64 coding of METADATA_BLOCK_PICTURE is invalid.", context);
|
||||||
throw InvalidDataException();
|
throw InvalidDataException();
|
||||||
|
} catch(...) {
|
||||||
|
catchIoFailure();
|
||||||
|
addNotification(NotificationType::Critical, "An IO error occured when reading the METADATA_BLOCK_PICTURE struct.", context);
|
||||||
|
throw Failure();
|
||||||
}
|
}
|
||||||
} else if(id().size() + 1 < size) {
|
} else if(id().size() + 1 < size) {
|
||||||
// extract other values (as string)
|
// extract other values (as string)
|
||||||
|
@ -186,7 +188,8 @@ bool VorbisCommentField::make(BinaryWriter &writer, VorbisCommentFlags flags)
|
||||||
|
|
||||||
pictureBlock.make(bufferStream);
|
pictureBlock.make(bufferStream);
|
||||||
valueString = encodeBase64(reinterpret_cast<byte *>(buffer.get()), requiredSize);
|
valueString = encodeBase64(reinterpret_cast<byte *>(buffer.get()), requiredSize);
|
||||||
} catch (const ios_base::failure &) {
|
} catch(...) {
|
||||||
|
catchIoFailure();
|
||||||
addNotification(NotificationType::Critical, "An IO error occured when writing the METADATA_BLOCK_PICTURE struct.", context);
|
addNotification(NotificationType::Critical, "An IO error occured when writing the METADATA_BLOCK_PICTURE struct.", context);
|
||||||
throw Failure();
|
throw Failure();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue