Use _wopen under Windows to support unicode filenames
This commit is contained in:
parent
e9166c19a5
commit
477ac9884b
|
@ -166,7 +166,7 @@ set(META_PUBLIC_STATIC_LIB_DEPENDS c++utilities_static)
|
|||
set(META_PRIVATE_COMPILE_DEFINITIONS LEGACY_API)
|
||||
|
||||
# find c++utilities
|
||||
find_package(c++utilities 4.0.0 REQUIRED)
|
||||
find_package(c++utilities 4.4.0 REQUIRED)
|
||||
use_cpp_utilities()
|
||||
|
||||
# find 3rd party libraries
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ string &backupDirectory()
|
|||
* \brief Restores the original file from the specified backup file.
|
||||
* \param originalPath Specifies the path to the original file.
|
||||
* \param backupPath Specifies the path to the backup file.
|
||||
* \param originalStream A std::fstream instance for the original file.
|
||||
* \param backupStream A std::fstream instance for the backup file.
|
||||
* \param originalStream Specifies a std::fstream instance for the original file.
|
||||
* \param backupStream Specifies a std::fstream instance for the backup file.
|
||||
*
|
||||
* This helper function is used by MediaFileInfo and container implementations
|
||||
* to restore the original file from the specified backup file in the case a Failure
|
||||
|
@ -60,7 +60,7 @@ string &backupDirectory()
|
|||
*
|
||||
* \throws Throws std::ios_base::failure on failure.
|
||||
*/
|
||||
void restoreOriginalFileFromBackupFile(const std::string &originalPath, const std::string &backupPath, std::fstream &originalStream, std::fstream &backupStream)
|
||||
void restoreOriginalFileFromBackupFile(const std::string &originalPath, const std::string &backupPath, NativeFileStream &originalStream, NativeFileStream &backupStream)
|
||||
{
|
||||
// ensure the orignal stream is closed
|
||||
if(originalStream.is_open()) {
|
||||
|
@ -117,7 +117,7 @@ void restoreOriginalFileFromBackupFile(const std::string &originalPath, const st
|
|||
*
|
||||
* \throws Throws std::ios_base::failure on failure.
|
||||
*/
|
||||
void createBackupFile(const std::string &originalPath, std::string &backupPath, std::fstream &originalStream, std::fstream &backupStream)
|
||||
void createBackupFile(const std::string &originalPath, std::string &backupPath, NativeFileStream &originalStream, NativeFileStream &backupStream)
|
||||
{
|
||||
// determine the backup path
|
||||
const string &backupDir = backupDirectory();
|
||||
|
@ -251,7 +251,7 @@ void createBackupFile(const std::string &originalPath, std::string &backupPath,
|
|||
* no backup file has been created.
|
||||
* \param context Specifies the context used to add notifications.
|
||||
*/
|
||||
void handleFailureAfterFileModified(MediaFileInfo &fileInfo, const std::string &backupPath, std::fstream &outputStream, std::fstream &backupStream, const std::string &context)
|
||||
void handleFailureAfterFileModified(MediaFileInfo &fileInfo, const std::string &backupPath, NativeFileStream &outputStream, NativeFileStream &backupStream, const std::string &context)
|
||||
{
|
||||
// reset the associated container in any case
|
||||
if(fileInfo.container()) {
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
#include "./global.h"
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <c++utilities/io/nativefilestream.h>
|
||||
|
||||
namespace Media {
|
||||
|
||||
|
@ -13,9 +12,9 @@ class MediaFileInfo;
|
|||
namespace BackupHelper {
|
||||
|
||||
TAG_PARSER_EXPORT std::string &backupDirectory();
|
||||
TAG_PARSER_EXPORT void restoreOriginalFileFromBackupFile(const std::string &originalPath, const std::string &backupPath, std::fstream &originalStream, std::fstream &backupStream);
|
||||
TAG_PARSER_EXPORT void createBackupFile(const std::string &originalPath, std::string &backupPath, std::fstream &originalStream, std::fstream &backupStream);
|
||||
TAG_PARSER_EXPORT void handleFailureAfterFileModified(MediaFileInfo &mediaFileInfo, const std::string &backupPath, std::fstream &outputStream, std::fstream &backupStream, const std::string &context = "making file");
|
||||
TAG_PARSER_EXPORT void restoreOriginalFileFromBackupFile(const std::string &originalPath, const std::string &backupPath, IoUtilities::NativeFileStream &originalStream, IoUtilities::NativeFileStream &backupStream);
|
||||
TAG_PARSER_EXPORT void createBackupFile(const std::string &originalPath, std::string &backupPath, IoUtilities::NativeFileStream &originalStream, IoUtilities::NativeFileStream &backupStream);
|
||||
TAG_PARSER_EXPORT void handleFailureAfterFileModified(MediaFileInfo &mediaFileInfo, const std::string &backupPath, IoUtilities::NativeFileStream &outputStream, IoUtilities::NativeFileStream &backupStream, const std::string &context = "making file");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ BasicFileInfo::BasicFileInfo(const std::string &path) :
|
|||
m_size(0),
|
||||
m_readOnly(false)
|
||||
{
|
||||
m_file.exceptions(fstream::failbit | fstream::badbit);
|
||||
m_file.exceptions(ios_base::failbit | ios_base::badbit);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -70,7 +70,7 @@ void BasicFileInfo::reopen(bool readOnly)
|
|||
*/
|
||||
void BasicFileInfo::close()
|
||||
{
|
||||
if(m_file.is_open()) {
|
||||
if(isOpen()) {
|
||||
m_file.close();
|
||||
}
|
||||
m_file.clear();
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include "./global.h"
|
||||
|
||||
#include <c++utilities/conversion/types.h>
|
||||
#include <c++utilities/io/nativefilestream.h>
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
namespace Media {
|
||||
|
||||
|
@ -26,8 +26,8 @@ public:
|
|||
bool isReadOnly() const;
|
||||
void close();
|
||||
void invalidate();
|
||||
std::fstream &stream();
|
||||
const std::fstream &stream() const;
|
||||
IoUtilities::NativeFileStream &stream();
|
||||
const IoUtilities::NativeFileStream &stream() const;
|
||||
|
||||
// methods to get, set path (components)
|
||||
const std::string &path() const;
|
||||
|
@ -51,7 +51,7 @@ protected:
|
|||
|
||||
private:
|
||||
std::string m_path;
|
||||
std::fstream m_file;
|
||||
IoUtilities::NativeFileStream m_file;
|
||||
uint64 m_size;
|
||||
bool m_readOnly;
|
||||
};
|
||||
|
@ -77,7 +77,7 @@ inline bool BasicFileInfo::isReadOnly() const
|
|||
/*!
|
||||
* \brief Returns the std::fstream for the current instance.
|
||||
*/
|
||||
inline std::fstream &BasicFileInfo::stream()
|
||||
inline IoUtilities::NativeFileStream &BasicFileInfo::stream()
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ inline std::fstream &BasicFileInfo::stream()
|
|||
/*!
|
||||
* \brief Returns the std::fstream for the current instance.
|
||||
*/
|
||||
inline const std::fstream &BasicFileInfo::stream() const
|
||||
inline const IoUtilities::NativeFileStream &BasicFileInfo::stream() const
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace IoUtilities {
|
||||
|
|
|
@ -1375,8 +1375,8 @@ nonRewriteCalculations:
|
|||
|
||||
// -> define variables needed to handle output stream and backup stream (required when rewriting the file)
|
||||
string backupPath;
|
||||
fstream &outputStream = fileInfo().stream();
|
||||
fstream backupStream; // create a stream to open the backup/original file for the case rewriting the file is required
|
||||
NativeFileStream &outputStream = fileInfo().stream();
|
||||
NativeFileStream backupStream; // create a stream to open the backup/original file for the case rewriting the file is required
|
||||
BinaryWriter outputWriter(&outputStream);
|
||||
char buff[8]; // buffer used to make size denotations
|
||||
|
||||
|
|
|
@ -1601,8 +1601,8 @@ void MediaFileInfo::makeMp3File()
|
|||
// setup stream(s) for writing
|
||||
// -> define variables needed to handle output stream and backup stream (required when rewriting the file)
|
||||
string backupPath;
|
||||
fstream &outputStream = stream();
|
||||
fstream backupStream; // create a stream to open the backup/original file for the case rewriting the file is required
|
||||
NativeFileStream &outputStream = stream();
|
||||
NativeFileStream backupStream; // create a stream to open the backup/original file for the case rewriting the file is required
|
||||
|
||||
if(rewriteRequired) {
|
||||
if(m_saveFilePath.empty()) {
|
||||
|
|
|
@ -520,8 +520,8 @@ calculatePadding:
|
|||
|
||||
// -> define variables needed to handle output stream and backup stream (required when rewriting the file)
|
||||
string backupPath;
|
||||
fstream &outputStream = fileInfo().stream();
|
||||
fstream backupStream; // create a stream to open the backup/original file for the case rewriting the file is required
|
||||
NativeFileStream &outputStream = fileInfo().stream();
|
||||
NativeFileStream backupStream; // create a stream to open the backup/original file for the case rewriting the file is required
|
||||
BinaryWriter outputWriter(&outputStream);
|
||||
|
||||
if(rewriteRequired) {
|
||||
|
|
|
@ -328,7 +328,7 @@ void OggContainer::internalMakeFile()
|
|||
updateStatus("Prepare for rewriting OGG file ...");
|
||||
parseTags(); // tags need to be parsed before the file can be rewritten
|
||||
string backupPath;
|
||||
fstream backupStream;
|
||||
NativeFileStream backupStream;
|
||||
|
||||
if(fileInfo().saveFilePath().empty()) {
|
||||
// move current file to temp dir and reopen it as backupStream, recreate original file
|
||||
|
|
1
tag.h
1
tag.h
|
@ -8,7 +8,6 @@
|
|||
#include <c++utilities/conversion/types.h>
|
||||
#include <c++utilities/io/binaryreader.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include "../abstracttrack.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace Media
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in New Issue