From: <man...@us...> - 2014-10-06 16:40:24
|
Revision: 4397 http://sourceforge.net/p/modplug/code/4397 Author: manxorist Date: 2014-10-06 16:40:16 +0000 (Mon, 06 Oct 2014) Log Message: ----------- [Ref] Invert NO_FILEREADER_STD_ISTREAM to MPT_FILEREADER_STD_ISTREAM for better code readability. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/soundlib/FileReader.h trunk/OpenMPT/soundlib/Load_itp.cpp trunk/OpenMPT/soundlib/Load_mt2.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2014-10-06 16:27:26 UTC (rev 4396) +++ trunk/OpenMPT/common/BuildSettings.h 2014-10-06 16:40:16 UTC (rev 4397) @@ -94,8 +94,8 @@ #define NO_ASSERTS #endif -// Disable std::istream support in class FileReader (this is generally not needed for the tracker, local files can easily be mmapped as they have been before introducing std::istream support) -#define NO_FILEREADER_STD_ISTREAM +// Enable std::istream support in class FileReader (this is generally not needed for the tracker, local files can easily be mmapped as they have been before introducing std::istream support) +//#define MPT_FILEREADER_STD_ISTREAM // Disable unarchiving support //#define NO_ARCHIVE_SUPPORT @@ -159,7 +159,7 @@ #endif //#define NO_ASSERTS //#define NO_LOGGING -//#define NO_FILEREADER_STD_ISTREAM +#define MPT_FILEREADER_STD_ISTREAM #define NO_ARCHIVE_SUPPORT #define NO_REVERB #define NO_DSP Modified: trunk/OpenMPT/soundlib/FileReader.h =================================================================== --- trunk/OpenMPT/soundlib/FileReader.h 2014-10-06 16:27:26 UTC (rev 4396) +++ trunk/OpenMPT/soundlib/FileReader.h 2014-10-06 16:40:16 UTC (rev 4397) @@ -16,7 +16,7 @@ #include "../common/misc_util.h" #include "../common/Endianness.h" #include <algorithm> -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) #include <ios> #include <istream> #endif @@ -33,7 +33,7 @@ #define FILEREADER_DEPRECATED -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) class IFileDataContainer { public: @@ -290,12 +290,12 @@ class FileDataContainerMemory -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) : public IFileDataContainer #endif { -#ifdef NO_FILEREADER_STD_ISTREAM +#if !defined(MPT_FILEREADER_STD_ISTREAM) public: typedef std::size_t off_t; #endif @@ -308,7 +308,7 @@ public: FileDataContainerMemory() : streamData(nullptr), streamLength(0) { } FileDataContainerMemory(const char *data, off_t length) : streamData(data), streamLength(length) { } -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) virtual #endif ~FileDataContainerMemory() { } @@ -374,7 +374,7 @@ public: -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) typedef IFileDataContainer::off_t off_t; #else typedef FileDataContainerMemory::off_t off_t; @@ -382,7 +382,7 @@ private: -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) const IFileDataContainer & DataContainer() const { return *data; } IFileDataContainer & DataContainer() { return *data; } MPT_SHARED_PTR<IFileDataContainer> data; @@ -396,7 +396,7 @@ public: -#ifndef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) // Initialize invalid file reader object. FileReader() : data(new FileDataContainerDummy()), streamPos(0) { } @@ -536,7 +536,7 @@ { return FileReader(); } - #ifndef NO_FILEREADER_STD_ISTREAM + #if defined(MPT_FILEREADER_STD_ISTREAM) return FileReader(MPT_SHARED_PTR<IFileDataContainer>(new FileDataContainerWindow(data, position, std::min(length, DataContainer().GetLength() - position)))); #else return FileReader(DataContainer().GetRawData() + position, std::min(length, DataContainer().GetLength() - position)); Modified: trunk/OpenMPT/soundlib/Load_itp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-06 16:27:26 UTC (rev 4396) +++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-10-06 16:40:16 UTC (rev 4397) @@ -20,7 +20,7 @@ #include "ITTools.h" #ifdef MODPLUG_TRACKER #include "../mptrack/TrackerSettings.h" -#ifdef NO_FILEREADER_STD_ISTREAM +#if !defined(MPT_FILEREADER_STD_ISTREAM) #include "../mptrack/MemoryMappedFile.h" #else #include "../common/mptFstream.h" @@ -259,16 +259,16 @@ { if(m_szInstrumentPath[ins].empty()) continue; -#ifdef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) + mpt::ifstream f(m_szInstrumentPath[ins], std::ios_base::binary); + if(!f.good()) + continue; + FileReader file(&f); +#else CMappedFile f; if(!f.Open(m_szInstrumentPath[ins])) continue; FileReader file = f.GetFile(); -#else - mpt::ifstream f(m_szInstrumentPath[ins], std::ios_base::binary); - if(!f.good()) - continue; - FileReader file(&f); #endif if(file.IsValid()) Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-06 16:27:26 UTC (rev 4396) +++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-10-06 16:40:16 UTC (rev 4397) @@ -13,10 +13,10 @@ #include "Loaders.h" #ifdef MODPLUG_TRACKER // For loading external samples -#ifdef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) +#include "../common/mptFstream.h" +#else #include "../mptrack/MemoryMappedFile.h" -#else -#include "../common/mptFstream.h" #endif #include "../mptrack/Moddoc.h" #endif @@ -1020,15 +1020,15 @@ path = path.RelativePathToAbsolute(GetpModDoc()->GetPathNameMpt().GetPath()); } -#ifdef NO_FILEREADER_STD_ISTREAM +#if defined(MPT_FILEREADER_STD_ISTREAM) + mpt::ifstream f(path, std::ios_base::binary); + if(f.good()) + sampleFile = FileReader(&f); +#else CMappedFile f; FileReader sampleFile; if(f.Open(path)) sampleFile = f.GetFile(); -#else - mpt::ifstream f(path, std::ios_base::binary); - if(f.good()) - sampleFile = FileReader(&f); #endif if(sampleFile.IsValid()) ReadSampleFromFile(i + 1, sampleFile, false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |