mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
- more filesystem logging and possible fix for Win
- added missing destructor for loaders - added missing override kewords - added unused for now ARCHIVE_ZIP filetype
This commit is contained in:
@@ -48,6 +48,11 @@ CFilesystemList::CFilesystemList()
|
|||||||
loaders = new std::vector<std::unique_ptr<ISimpleResourceLoader> >;
|
loaders = new std::vector<std::unique_ptr<ISimpleResourceLoader> >;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CFilesystemList::~CFilesystemList()
|
||||||
|
{
|
||||||
|
delete loaders;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<CInputStream> CFilesystemList::load(const ResourceID & resourceName) const
|
std::unique_ptr<CInputStream> CFilesystemList::load(const ResourceID & resourceName) const
|
||||||
{
|
{
|
||||||
// load resource from last loader that have it (last overriden version)
|
// load resource from last loader that have it (last overriden version)
|
||||||
|
@@ -59,6 +59,7 @@ class DLL_LINKAGE CFilesystemList : public ISimpleResourceLoader
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CFilesystemList();
|
CFilesystemList();
|
||||||
|
~CFilesystemList();
|
||||||
/// Interface implementation
|
/// Interface implementation
|
||||||
/// @see ISimpleResourceLoader
|
/// @see ISimpleResourceLoader
|
||||||
std::unique_ptr<CInputStream> load(const ResourceID & resourceName) const override;
|
std::unique_ptr<CInputStream> load(const ResourceID & resourceName) const override;
|
||||||
|
@@ -46,6 +46,7 @@ CArchiveLoader::CArchiveLoader(const std::string &mountPoint, const std::string
|
|||||||
{
|
{
|
||||||
throw std::runtime_error("LOD archive format unknown. Cannot deal with " + archive);
|
throw std::runtime_error("LOD archive format unknown. Cannot deal with " + archive);
|
||||||
}
|
}
|
||||||
|
logGlobal->traceStream() << "Archive loaded, " << entries.size() << " files found";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CArchiveLoader::initLODArchive(const std::string &mountPoint, CFileInputStream & fileStream)
|
void CArchiveLoader::initLODArchive(const std::string &mountPoint, CFileInputStream & fileStream)
|
||||||
|
@@ -46,7 +46,7 @@ public:
|
|||||||
* @param size The number of bytes to read.
|
* @param size The number of bytes to read.
|
||||||
* @return the number of bytes read actually.
|
* @return the number of bytes read actually.
|
||||||
*/
|
*/
|
||||||
si64 read(ui8 * data, si64 size);
|
si64 read(ui8 * data, si64 size) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seeks the internal read pointer to the specified position.
|
* Seeks the internal read pointer to the specified position.
|
||||||
@@ -54,14 +54,14 @@ public:
|
|||||||
* @param position The read position from the beginning.
|
* @param position The read position from the beginning.
|
||||||
* @return the position actually moved to, -1 on error.
|
* @return the position actually moved to, -1 on error.
|
||||||
*/
|
*/
|
||||||
si64 seek(si64 position);
|
si64 seek(si64 position) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current read position in the stream.
|
* Gets the current read position in the stream.
|
||||||
*
|
*
|
||||||
* @return the read position. -1 on failure or if the read pointer isn't in the valid range.
|
* @return the read position. -1 on failure or if the read pointer isn't in the valid range.
|
||||||
*/
|
*/
|
||||||
si64 tell();
|
si64 tell() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skips delta numbers of bytes.
|
* Skips delta numbers of bytes.
|
||||||
@@ -69,14 +69,14 @@ public:
|
|||||||
* @param delta The count of bytes to skip.
|
* @param delta The count of bytes to skip.
|
||||||
* @return the count of bytes skipped actually.
|
* @return the count of bytes skipped actually.
|
||||||
*/
|
*/
|
||||||
si64 skip(si64 delta);
|
si64 skip(si64 delta) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the length in bytes of the stream.
|
* Gets the length in bytes of the stream.
|
||||||
*
|
*
|
||||||
* @return the length in bytes of the stream.
|
* @return the length in bytes of the stream.
|
||||||
*/
|
*/
|
||||||
si64 getSize();
|
si64 getSize() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
@@ -9,6 +9,7 @@ CFilesystemLoader::CFilesystemLoader(const std::string &mountPoint, const std::s
|
|||||||
mountPoint(mountPoint),
|
mountPoint(mountPoint),
|
||||||
fileList(listFiles(mountPoint, depth, initial))
|
fileList(listFiles(mountPoint, depth, initial))
|
||||||
{
|
{
|
||||||
|
logGlobal->traceStream() << "Filesystem loaded, " << fileList.size() << " files found";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CInputStream> CFilesystemLoader::load(const ResourceID & resourceName) const
|
std::unique_ptr<CInputStream> CFilesystemLoader::load(const ResourceID & resourceName) const
|
||||||
@@ -97,8 +98,8 @@ std::unordered_map<ResourceID, std::string> CFilesystemLoader::listFiles(const s
|
|||||||
{
|
{
|
||||||
path.resize(it.level()+1);
|
path.resize(it.level()+1);
|
||||||
path.back() = it->path().leaf().string();
|
path.back() = it->path().leaf().string();
|
||||||
// don't iterate into directory if depth limit reached OR into hidden directories (like .svn)
|
// don't iterate into directory if depth limit reached
|
||||||
it.no_push(depth <= it.level() || it->path().leaf().string()[0] == '.');
|
it.no_push(depth <= it.level());
|
||||||
|
|
||||||
type = EResType::DIRECTORY;
|
type = EResType::DIRECTORY;
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ public:
|
|||||||
* @param size The number of bytes to read.
|
* @param size The number of bytes to read.
|
||||||
* @return the number of bytes read actually.
|
* @return the number of bytes read actually.
|
||||||
*/
|
*/
|
||||||
si64 read(ui8 * data, si64 size);
|
si64 read(ui8 * data, si64 size) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seeks the internal read pointer to the specified position.
|
* Seeks the internal read pointer to the specified position.
|
||||||
@@ -41,14 +41,14 @@ public:
|
|||||||
* @param position The read position from the beginning.
|
* @param position The read position from the beginning.
|
||||||
* @return the position actually moved to, -1 on error.
|
* @return the position actually moved to, -1 on error.
|
||||||
*/
|
*/
|
||||||
si64 seek(si64 position);
|
si64 seek(si64 position) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current read position in the stream.
|
* Gets the current read position in the stream.
|
||||||
*
|
*
|
||||||
* @return the read position.
|
* @return the read position.
|
||||||
*/
|
*/
|
||||||
si64 tell();
|
si64 tell() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skips delta numbers of bytes.
|
* Skips delta numbers of bytes.
|
||||||
@@ -56,14 +56,14 @@ public:
|
|||||||
* @param delta The count of bytes to skip.
|
* @param delta The count of bytes to skip.
|
||||||
* @return the count of bytes skipped actually.
|
* @return the count of bytes skipped actually.
|
||||||
*/
|
*/
|
||||||
si64 skip(si64 delta);
|
si64 skip(si64 delta) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the length in bytes of the stream.
|
* Gets the length in bytes of the stream.
|
||||||
*
|
*
|
||||||
* @return the length in bytes of the stream.
|
* @return the length in bytes of the stream.
|
||||||
*/
|
*/
|
||||||
si64 getSize();
|
si64 getSize() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** A pointer to the data array. */
|
/** A pointer to the data array. */
|
||||||
|
@@ -97,6 +97,7 @@ EResType::Type EResTypeHelper::getTypeFromExtension(std::string extension)
|
|||||||
(".AVI", EResType::VIDEO)
|
(".AVI", EResType::VIDEO)
|
||||||
(".MP3", EResType::MUSIC)
|
(".MP3", EResType::MUSIC)
|
||||||
(".OGG", EResType::MUSIC)
|
(".OGG", EResType::MUSIC)
|
||||||
|
(".ZIP", EResType::ARCHIVE_ZIP)
|
||||||
(".LOD", EResType::ARCHIVE_LOD)
|
(".LOD", EResType::ARCHIVE_LOD)
|
||||||
(".PAC", EResType::ARCHIVE_LOD)
|
(".PAC", EResType::ARCHIVE_LOD)
|
||||||
(".VID", EResType::ARCHIVE_VID)
|
(".VID", EResType::ARCHIVE_VID)
|
||||||
@@ -130,6 +131,7 @@ std::string EResTypeHelper::getEResTypeAsString(EResType::Type type)
|
|||||||
MAP_ENUM(VIDEO)
|
MAP_ENUM(VIDEO)
|
||||||
MAP_ENUM(SOUND)
|
MAP_ENUM(SOUND)
|
||||||
MAP_ENUM(MUSIC)
|
MAP_ENUM(MUSIC)
|
||||||
|
MAP_ENUM(ARCHIVE_ZIP)
|
||||||
MAP_ENUM(ARCHIVE_LOD)
|
MAP_ENUM(ARCHIVE_LOD)
|
||||||
MAP_ENUM(ARCHIVE_SND)
|
MAP_ENUM(ARCHIVE_SND)
|
||||||
MAP_ENUM(ARCHIVE_VID)
|
MAP_ENUM(ARCHIVE_VID)
|
||||||
|
@@ -51,6 +51,7 @@ namespace EResType
|
|||||||
SOUND,
|
SOUND,
|
||||||
MUSIC,
|
MUSIC,
|
||||||
ARCHIVE_VID,
|
ARCHIVE_VID,
|
||||||
|
ARCHIVE_ZIP,
|
||||||
ARCHIVE_SND,
|
ARCHIVE_SND,
|
||||||
ARCHIVE_LOD,
|
ARCHIVE_LOD,
|
||||||
PALETTE,
|
PALETTE,
|
||||||
|
@@ -72,7 +72,7 @@ CLogger * CLogger::getLogger(const CLoggerDomain & domain)
|
|||||||
logger = new CLogger(domain);
|
logger = new CLogger(domain);
|
||||||
if(domain.isGlobalDomain())
|
if(domain.isGlobalDomain())
|
||||||
{
|
{
|
||||||
logger->setLevel(ELogLevel::INFO);
|
logger->setLevel(ELogLevel::TRACE);
|
||||||
}
|
}
|
||||||
CLogManager::get().addLogger(logger);
|
CLogManager::get().addLogger(logger);
|
||||||
return logger;
|
return logger;
|
||||||
@@ -88,7 +88,7 @@ CLogger::CLogger(const CLoggerDomain & domain) : domain(domain)
|
|||||||
{
|
{
|
||||||
if(domain.isGlobalDomain())
|
if(domain.isGlobalDomain())
|
||||||
{
|
{
|
||||||
level = ELogLevel::INFO;
|
level = ELogLevel::TRACE;
|
||||||
parent = nullptr;
|
parent = nullptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user