mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-18 10:35:46 -04:00
Sync filesystem.h/path.h
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include "common/crash_handler.h"
|
||||
#include "common/file_system.h"
|
||||
#include "common/log.h"
|
||||
#include "common/path.h"
|
||||
#include "common/string_util.h"
|
||||
#include "controller_interface.h"
|
||||
#include "core/cdrom.h"
|
||||
@ -3074,7 +3075,7 @@ void CommonHostInterface::RenameCurrentSaveStateToBackup(const char* filename)
|
||||
if (!FileSystem::FileExists(filename))
|
||||
return;
|
||||
|
||||
const std::string backup_filename(FileSystem::ReplaceExtension(filename, "bak"));
|
||||
const std::string backup_filename(Path::ReplaceExtension(filename, "bak"));
|
||||
if (!FileSystem::RenamePath(filename, backup_filename.c_str()))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to rename save state backup '%s'", backup_filename.c_str());
|
||||
@ -3094,8 +3095,7 @@ std::vector<CommonHostInterface::SaveStateInfo> CommonHostInterface::GetAvailabl
|
||||
if (!FileSystem::StatFile(path.c_str(), &sd))
|
||||
return;
|
||||
|
||||
si.push_back(SaveStateInfo{std::move(path), static_cast<std::time_t>(sd.ModificationTime.AsUnixTimestamp()),
|
||||
static_cast<s32>(slot), global});
|
||||
si.push_back(SaveStateInfo{std::move(path), sd.ModificationTime, static_cast<s32>(slot), global});
|
||||
};
|
||||
|
||||
if (game_code && std::strlen(game_code) > 0)
|
||||
@ -3120,7 +3120,7 @@ std::optional<CommonHostInterface::SaveStateInfo> CommonHostInterface::GetSaveSt
|
||||
if (!FileSystem::StatFile(path.c_str(), &sd))
|
||||
return std::nullopt;
|
||||
|
||||
return SaveStateInfo{std::move(path), static_cast<std::time_t>(sd.ModificationTime.AsUnixTimestamp()), slot, global};
|
||||
return SaveStateInfo{std::move(path), sd.ModificationTime, slot, global};
|
||||
}
|
||||
|
||||
std::optional<CommonHostInterface::ExtendedSaveStateInfo>
|
||||
@ -3193,7 +3193,7 @@ CommonHostInterface::GetExtendedSaveStateInfo(const char* game_code, s32 slot)
|
||||
return std::nullopt;
|
||||
|
||||
ssi->path = std::move(path);
|
||||
ssi->timestamp = sd.ModificationTime.AsUnixTimestamp();
|
||||
ssi->timestamp = sd.ModificationTime;
|
||||
ssi->slot = slot;
|
||||
ssi->global = global;
|
||||
|
||||
@ -3650,7 +3650,8 @@ void CommonHostInterface::GetGameInfo(const char* path, CDImage* image, std::str
|
||||
*code = System::GetGameCodeForImage(image, true);
|
||||
}
|
||||
|
||||
*title = FileSystem::GetFileTitleFromPath(path);
|
||||
const std::string display_name(FileSystem::GetDisplayNameFromPath(path));
|
||||
*title = Path::GetFileTitle(display_name);
|
||||
}
|
||||
|
||||
bool CommonHostInterface::SaveResumeSaveState()
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "common/file_system.h"
|
||||
#include "common/log.h"
|
||||
#include "common/make_array.h"
|
||||
#include "common/path.h"
|
||||
#include "common/string.h"
|
||||
#include "common/string_util.h"
|
||||
#include "common_host_interface.h"
|
||||
@ -688,7 +689,7 @@ static void DoChangeDiscFromFile()
|
||||
};
|
||||
|
||||
OpenFileSelector(ICON_FA_COMPACT_DISC " Select Disc Image", false, std::move(callback), GetDiscImageFilters(),
|
||||
std::string(FileSystem::GetPathDirectory(System::GetMediaFileName())));
|
||||
std::string(Path::GetDirectory(System::GetMediaFileName())));
|
||||
}
|
||||
|
||||
static void DoChangeDisc()
|
||||
@ -1120,7 +1121,7 @@ static bool SettingInfoButton(const SettingInfo& si, const char* section)
|
||||
CloseFileSelector();
|
||||
};
|
||||
OpenFileSelector(si.visible_name, false, std::move(callback), ImGuiFullscreen::FileSelectorFilters(),
|
||||
std::string(FileSystem::GetPathDirectory(std::move(value))));
|
||||
std::string(Path::GetDirectory(std::move(value))));
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -2604,7 +2605,7 @@ void DrawQuickMenu(MainWindowType type)
|
||||
SmallString subtitle;
|
||||
if (!code.empty())
|
||||
subtitle.Format("%s - ", code.c_str());
|
||||
subtitle.AppendString(FileSystem::GetFileNameFromPath(System::GetRunningPath()));
|
||||
subtitle.AppendString(Path::GetFileTitle(System::GetRunningPath()));
|
||||
|
||||
const ImVec2 title_size(
|
||||
g_large_font->CalcTextSizeA(g_large_font->FontSize, std::numeric_limits<float>::max(), -1.0f, title.c_str()));
|
||||
@ -3092,7 +3093,7 @@ void DrawGameListWindow()
|
||||
else
|
||||
summary.Format("%s - %s - ", entry->code.c_str(), Settings::GetDiscRegionName(entry->region));
|
||||
|
||||
summary.AppendString(FileSystem::GetFileNameFromPath(entry->path));
|
||||
summary.AppendString(Path::GetFileName(entry->path));
|
||||
|
||||
ImGui::GetWindowDrawList()->AddImage(cover_texture->GetHandle(), bb.Min, bb.Min + image_size, ImVec2(0.0f, 0.0f),
|
||||
ImVec2(1.0f, 1.0f), IM_COL32(255, 255, 255, 255));
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "common/iso_reader.h"
|
||||
#include "common/log.h"
|
||||
#include "common/make_array.h"
|
||||
#include "common/path.h"
|
||||
#include "common/progress_callback.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/bios.h"
|
||||
@ -91,7 +92,7 @@ bool GameList::GetExeListEntry(const std::string& path, GameListEntry* entry)
|
||||
|
||||
const std::string display_name(FileSystem::GetDisplayNameFromPath(path));
|
||||
entry->code.clear();
|
||||
entry->title = FileSystem::StripExtension(display_name);
|
||||
entry->title = Path::StripExtension(display_name);
|
||||
entry->region = BIOS::GetPSExeDiscRegion(header);
|
||||
entry->total_size = ZeroExtend64(file_size);
|
||||
entry->type = GameListEntryType::PSExe;
|
||||
@ -133,7 +134,7 @@ bool GameList::GetPsfListEntry(const std::string& path, GameListEntry* entry)
|
||||
else
|
||||
{
|
||||
const std::string display_name(FileSystem::GetDisplayNameFromPath(path));
|
||||
entry->title += FileSystem::StripExtension(display_name);
|
||||
entry->title += Path::StripExtension(display_name);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -160,9 +161,11 @@ bool GameList::GetGameListEntry(const std::string& path, GameListEntry* entry)
|
||||
GameDatabaseEntry dbentry;
|
||||
if (!m_database.GetEntryForDisc(cdi.get(), &dbentry))
|
||||
{
|
||||
const std::string display_name(FileSystem::GetDisplayNameFromPath(path));
|
||||
|
||||
// no game code, so use the filename title
|
||||
entry->code = System::GetGameCodeForImage(cdi.get(), true);
|
||||
entry->title = FileSystem::GetFileTitleFromPath(path);
|
||||
entry->title = Path::GetFileTitle(display_name);
|
||||
entry->compatibility_rating = GameListCompatibilityRating::Unknown;
|
||||
entry->release_date = 0;
|
||||
entry->min_players = 0;
|
||||
@ -492,20 +495,19 @@ void GameList::ScanDirectory(const char* path, bool recursive, ProgressCallback*
|
||||
if (!IsScannableFilename(ffd.FileName) || IsPathExcluded(ffd.FileName) || GetEntryForPath(ffd.FileName.c_str()))
|
||||
continue;
|
||||
|
||||
const u64 modified_time = ffd.ModificationTime.AsUnixTimestamp();
|
||||
if (AddFileFromCache(ffd.FileName, modified_time))
|
||||
if (AddFileFromCache(ffd.FileName, ffd.ModificationTime))
|
||||
continue;
|
||||
|
||||
// ownership of fp is transferred
|
||||
progress->SetFormattedStatusText("Scanning '%s'...", FileSystem::GetDisplayNameFromPath(ffd.FileName).c_str());
|
||||
ScanFile(std::move(ffd.FileName), modified_time);
|
||||
ScanFile(std::move(ffd.FileName), ffd.ModificationTime);
|
||||
}
|
||||
|
||||
progress->SetProgressValue(static_cast<u32>(files.size()));
|
||||
progress->PopState();
|
||||
}
|
||||
|
||||
bool GameList::AddFileFromCache(const std::string& path, u64 timestamp)
|
||||
bool GameList::AddFileFromCache(const std::string& path, std::time_t timestamp)
|
||||
{
|
||||
if (std::any_of(m_entries.begin(), m_entries.end(),
|
||||
[&path](const GameListEntry& other) { return other.path == path; }))
|
||||
@ -515,14 +517,14 @@ bool GameList::AddFileFromCache(const std::string& path, u64 timestamp)
|
||||
}
|
||||
|
||||
GameListEntry entry;
|
||||
if (!GetGameListEntryFromCache(path, &entry) || entry.last_modified_time != timestamp)
|
||||
if (!GetGameListEntryFromCache(path, &entry) || entry.last_modified_time != static_cast<u64>(timestamp))
|
||||
return false;
|
||||
|
||||
m_entries.push_back(std::move(entry));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameList::ScanFile(std::string path, u64 timestamp)
|
||||
bool GameList::ScanFile(std::string path, std::time_t timestamp)
|
||||
{
|
||||
Log_DevPrintf("Scanning '%s'...", path.c_str());
|
||||
|
||||
@ -531,7 +533,7 @@ bool GameList::ScanFile(std::string path, u64 timestamp)
|
||||
return false;
|
||||
|
||||
entry.path = std::move(path);
|
||||
entry.last_modified_time = timestamp;
|
||||
entry.last_modified_time = static_cast<u64>(timestamp);
|
||||
|
||||
if (m_cache_write_stream || OpenCacheForWriting())
|
||||
{
|
||||
@ -1078,7 +1080,8 @@ std::string GameList::GetCoverImagePath(const std::string& path, const std::stri
|
||||
for (const char* extension : extensions)
|
||||
{
|
||||
// use the file title if it differs (e.g. modded games)
|
||||
const std::string_view file_title(FileSystem::GetFileTitleFromPath(path));
|
||||
const std::string display_name(FileSystem::GetDisplayNameFromPath(path));
|
||||
const std::string_view file_title(Path::GetFileTitle(display_name));
|
||||
if (!file_title.empty() && title != file_title)
|
||||
{
|
||||
cover_path.Clear();
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "core/types.h"
|
||||
#include "game_database.h"
|
||||
#include "game_settings.h"
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@ -152,8 +153,8 @@ private:
|
||||
bool GetGameListEntry(const std::string& path, GameListEntry* entry);
|
||||
bool GetGameListEntryFromCache(const std::string& path, GameListEntry* entry);
|
||||
void ScanDirectory(const char* path, bool recursive, ProgressCallback* progress);
|
||||
bool AddFileFromCache(const std::string& path, u64 timestamp);
|
||||
bool ScanFile(std::string path, u64 timestamp);
|
||||
bool AddFileFromCache(const std::string& path, std::time_t timestamp);
|
||||
bool ScanFile(std::string path, std::time_t timestamp);
|
||||
|
||||
void LoadCache();
|
||||
bool LoadEntriesFromCache(ByteStream* stream);
|
||||
|
@ -76,7 +76,7 @@
|
||||
#endif
|
||||
|
||||
// GL includes
|
||||
#include <glad.h>
|
||||
#include "common/gl/loader.h"
|
||||
|
||||
// OpenGL Data
|
||||
static char g_GlslVersionString[32] = "";
|
||||
|
@ -1,14 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
// GLAD has to come first so that Qt doesn't pull in the system GL headers, which are incompatible with glad.
|
||||
#include <glad.h>
|
||||
|
||||
// Hack to prevent Apple's glext.h headers from getting included via qopengl.h, since we still want to use glad.
|
||||
#ifdef __APPLE__
|
||||
#define __glext_h_
|
||||
#endif
|
||||
|
||||
#include "common/gl/context.h"
|
||||
#include "common/gl/loader.h"
|
||||
#include "common/gl/program.h"
|
||||
#include "common/gl/stream_buffer.h"
|
||||
#include "common/gl/texture.h"
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "save_state_selector_ui.h"
|
||||
#include "common/log.h"
|
||||
#include "common/string_util.h"
|
||||
#include "common/timestamp.h"
|
||||
#include "core/host_display.h"
|
||||
#include "core/system.h"
|
||||
#include "fmt/chrono.h"
|
||||
|
Reference in New Issue
Block a user