mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
Merge pull request #4901 from JosJuice/filemonitor-redesign
FileMonitor redesign
This commit is contained in:
@ -7,7 +7,6 @@ set(SRCS
|
||||
DriveBlob.cpp
|
||||
Enums.cpp
|
||||
FileBlob.cpp
|
||||
FileMonitor.cpp
|
||||
FileSystemGCWii.cpp
|
||||
Filesystem.cpp
|
||||
NANDContentLoader.cpp
|
||||
|
@ -42,7 +42,6 @@
|
||||
<ClCompile Include="DriveBlob.cpp" />
|
||||
<ClCompile Include="Enums.cpp" />
|
||||
<ClCompile Include="FileBlob.cpp" />
|
||||
<ClCompile Include="FileMonitor.cpp" />
|
||||
<ClCompile Include="Filesystem.cpp" />
|
||||
<ClCompile Include="FileSystemGCWii.cpp" />
|
||||
<ClCompile Include="NANDContentLoader.cpp" />
|
||||
@ -64,7 +63,6 @@
|
||||
<ClInclude Include="DriveBlob.h" />
|
||||
<ClInclude Include="Enums.h" />
|
||||
<ClInclude Include="FileBlob.h" />
|
||||
<ClInclude Include="FileMonitor.h" />
|
||||
<ClInclude Include="Filesystem.h" />
|
||||
<ClInclude Include="FileSystemGCWii.h" />
|
||||
<ClInclude Include="NANDContentLoader.h" />
|
||||
|
@ -51,9 +51,6 @@
|
||||
<ClCompile Include="WbfsBlob.cpp">
|
||||
<Filter>Volume\Blob</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FileMonitor.cpp">
|
||||
<Filter>Volume</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VolumeCreator.cpp">
|
||||
<Filter>Volume</Filter>
|
||||
</ClCompile>
|
||||
@ -113,9 +110,6 @@
|
||||
<ClInclude Include="WbfsBlob.h">
|
||||
<Filter>Volume\Blob</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FileMonitor.h">
|
||||
<Filter>Volume</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Volume.h">
|
||||
<Filter>Volume</Filter>
|
||||
</ClInclude>
|
||||
|
@ -1,151 +0,0 @@
|
||||
// Copyright 2009 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Logging/LogManager.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/Boot/Boot.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/FileMonitor.h"
|
||||
#include "DiscIO/Filesystem.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
#include "DiscIO/VolumeCreator.h"
|
||||
|
||||
namespace FileMon
|
||||
{
|
||||
static std::unique_ptr<DiscIO::IVolume> s_open_iso;
|
||||
static std::unique_ptr<DiscIO::IFileSystem> s_filesystem;
|
||||
static std::string ISOFile = "", CurrentFile = "";
|
||||
static bool FileAccess = true;
|
||||
|
||||
// Filtered files
|
||||
bool IsSoundFile(const std::string& filename)
|
||||
{
|
||||
std::string extension;
|
||||
SplitPath(filename, nullptr, nullptr, &extension);
|
||||
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
|
||||
|
||||
static std::unordered_set<std::string> extensions = {
|
||||
".adp", // 1080 Avalanche, Crash Bandicoot, etc.
|
||||
".adx", // Sonic Adventure 2 Battle, etc.
|
||||
".afc", // Zelda WW
|
||||
".ast", // Zelda TP, Mario Kart
|
||||
".brstm", // Wii Sports, Wario Land, etc.
|
||||
".dsp", // Metroid Prime
|
||||
".hps", // SSB Melee
|
||||
".ogg", // Tony Hawk's Underground 2
|
||||
".sad", // Disaster
|
||||
".snd", // Tales of Symphonia
|
||||
".song", // Tales of Symphonia
|
||||
".ssm", // Custom Robo, Kirby Air Ride, etc.
|
||||
".str", // Harry Potter & the Sorcerer's Stone
|
||||
};
|
||||
|
||||
return extensions.find(extension) != extensions.end();
|
||||
}
|
||||
|
||||
// Read the file system
|
||||
void ReadFileSystem(const std::string& filename)
|
||||
{
|
||||
// Should have an actual Shutdown procedure or something
|
||||
s_open_iso.reset();
|
||||
s_filesystem.reset();
|
||||
|
||||
s_open_iso = DiscIO::CreateVolumeFromFilename(filename);
|
||||
if (!s_open_iso)
|
||||
return;
|
||||
|
||||
if (s_open_iso->GetVolumeType() != DiscIO::Platform::WII_WAD)
|
||||
{
|
||||
s_filesystem = DiscIO::CreateFileSystem(s_open_iso.get());
|
||||
|
||||
if (!s_filesystem)
|
||||
return;
|
||||
}
|
||||
|
||||
FileAccess = true;
|
||||
}
|
||||
|
||||
// Logs a file if it passes a few checks
|
||||
void CheckFile(const std::string& file, u64 size)
|
||||
{
|
||||
// Don't do anything if the log is unselected
|
||||
if (!LogManager::GetInstance()->IsEnabled(LogTypes::FILEMON, LogTypes::LWARNING))
|
||||
return;
|
||||
// Do nothing if we found the same file again
|
||||
if (CurrentFile == file)
|
||||
return;
|
||||
|
||||
if (size > 0)
|
||||
size = (size / 1000);
|
||||
|
||||
std::string str = StringFromFormat("%s kB %s", ThousandSeparate(size, 7).c_str(), file.c_str());
|
||||
if (IsSoundFile(file))
|
||||
{
|
||||
INFO_LOG(FILEMON, "%s", str.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(FILEMON, "%s", str.c_str());
|
||||
}
|
||||
|
||||
// Update the current file
|
||||
CurrentFile = file;
|
||||
}
|
||||
|
||||
// Find the filename
|
||||
void FindFilename(u64 offset)
|
||||
{
|
||||
// Don't do anything if a game is not running
|
||||
if (Core::GetState() != Core::State::Running)
|
||||
return;
|
||||
|
||||
// Or if the log is unselected
|
||||
if (!LogManager::GetInstance()->IsEnabled(LogTypes::FILEMON, LogTypes::LWARNING))
|
||||
return;
|
||||
|
||||
// Or if we don't have file access
|
||||
if (!FileAccess)
|
||||
return;
|
||||
|
||||
if (!s_filesystem || ISOFile != SConfig::GetInstance().m_LastFilename)
|
||||
{
|
||||
FileAccess = false;
|
||||
ReadFileSystem(SConfig::GetInstance().m_LastFilename);
|
||||
ISOFile = SConfig::GetInstance().m_LastFilename;
|
||||
INFO_LOG(FILEMON, "Opening '%s'", ISOFile.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string filename = s_filesystem->GetFileName(offset);
|
||||
|
||||
if (filename.empty())
|
||||
return;
|
||||
|
||||
CheckFile(filename, s_filesystem->GetFileSize(filename));
|
||||
}
|
||||
|
||||
void Close()
|
||||
{
|
||||
s_open_iso.reset();
|
||||
s_filesystem.reset();
|
||||
|
||||
ISOFile = "";
|
||||
CurrentFile = "";
|
||||
FileAccess = true;
|
||||
}
|
||||
|
||||
} // FileMon
|
@ -1,18 +0,0 @@
|
||||
// Copyright 2008 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
namespace FileMon
|
||||
{
|
||||
bool IsSoundFile(const std::string& filename);
|
||||
void ReadFileSystem(const std::string& file);
|
||||
void CheckFile(const std::string& file, u64 size);
|
||||
void FindFilename(u64 offset);
|
||||
void Close();
|
||||
}
|
@ -18,6 +18,9 @@ IFileSystem::~IFileSystem()
|
||||
|
||||
std::unique_ptr<IFileSystem> CreateFileSystem(const IVolume* volume)
|
||||
{
|
||||
if (!volume)
|
||||
return nullptr;
|
||||
|
||||
std::unique_ptr<IFileSystem> filesystem = std::make_unique<CFileSystemGCWii>(volume);
|
||||
|
||||
if (!filesystem)
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/FileMonitor.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
#include "DiscIO/VolumeDirectory.h"
|
||||
|
||||
@ -130,8 +129,6 @@ bool CVolumeDirectory::Read(u64 offset, u64 length, u8* buffer, bool decrypt) co
|
||||
|
||||
u64 fileSize = file.GetSize();
|
||||
|
||||
FileMon::CheckFile(fileName, fileSize);
|
||||
|
||||
if (fileOffset < fileSize)
|
||||
{
|
||||
u64 fileBytes = std::min(fileSize - fileOffset, length);
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "Common/StringUtil.h"
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/FileMonitor.h"
|
||||
#include "DiscIO/Filesystem.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
#include "DiscIO/VolumeGC.h"
|
||||
@ -38,8 +37,6 @@ bool CVolumeGC::Read(u64 _Offset, u64 _Length, u8* _pBuffer, bool decrypt) const
|
||||
if (decrypt)
|
||||
PanicAlertT("Tried to decrypt data from a non-Wii volume");
|
||||
|
||||
FileMon::FindFilename(_Offset);
|
||||
|
||||
return m_pReader->Read(_Offset, _Length, _pBuffer);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include "DiscIO/Blob.h"
|
||||
#include "DiscIO/Enums.h"
|
||||
#include "DiscIO/FileMonitor.h"
|
||||
#include "DiscIO/Filesystem.h"
|
||||
#include "DiscIO/Volume.h"
|
||||
#include "DiscIO/VolumeCreator.h"
|
||||
@ -59,8 +58,6 @@ bool CVolumeWiiCrypted::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer, bool de
|
||||
if (!decrypt)
|
||||
return m_pReader->Read(_ReadOffset, _Length, _pBuffer);
|
||||
|
||||
FileMon::FindFilename(_ReadOffset);
|
||||
|
||||
std::vector<u8> read_buffer(BLOCK_TOTAL_SIZE);
|
||||
while (_Length > 0)
|
||||
{
|
||||
|
Reference in New Issue
Block a user