mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-21 07:25:39 -04:00
Sync filesystem.h/path.h
This commit is contained in:
@ -69,6 +69,7 @@ add_library(common
|
||||
memory_arena.h
|
||||
page_fault_handler.cpp
|
||||
page_fault_handler.h
|
||||
path.h
|
||||
platform.h
|
||||
pbp_types.h
|
||||
progress_callback.cpp
|
||||
@ -87,8 +88,6 @@ add_library(common
|
||||
thirdparty/thread_pool.h
|
||||
timer.cpp
|
||||
timer.h
|
||||
timestamp.cpp
|
||||
timestamp.h
|
||||
types.h
|
||||
vulkan/builders.cpp
|
||||
vulkan/builders.h
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "assert.h"
|
||||
#include "file_system.h"
|
||||
#include "log.h"
|
||||
#include "path.h"
|
||||
#include "string_util.h"
|
||||
#include <array>
|
||||
Log_SetChannel(CDImage);
|
||||
@ -293,7 +294,7 @@ std::string CDImage::GetMetadata(const std::string_view& type) const
|
||||
if (type == "title")
|
||||
{
|
||||
const std::string display_name(FileSystem::GetDisplayNameFromPath(m_filename));
|
||||
result = FileSystem::StripExtension(display_name);
|
||||
result = Path::StripExtension(display_name);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -303,7 +303,7 @@ bool CDImageCHD::HasNonStandardSubchannel() const
|
||||
|
||||
CDImage::PrecacheResult CDImageCHD::Precache(ProgressCallback* progress)
|
||||
{
|
||||
const std::string_view title(FileSystem::GetFileNameFromPath(m_filename));
|
||||
const std::string_view title(FileSystem::GetDisplayNameFromPath(m_filename));
|
||||
progress->SetFormattedStatusText("Precaching %.*s...", static_cast<int>(title.size()), title.data());
|
||||
progress->SetProgressRange(100);
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "error.h"
|
||||
#include "file_system.h"
|
||||
#include "log.h"
|
||||
#include "path.h"
|
||||
#include <algorithm>
|
||||
#include <cerrno>
|
||||
#include <cinttypes>
|
||||
@ -88,15 +89,14 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Common::Error* error)
|
||||
}
|
||||
if (track_file_index == m_files.size())
|
||||
{
|
||||
const std::string track_full_filename(!FileSystem::IsAbsolutePath(track_filename) ?
|
||||
FileSystem::BuildRelativePath(m_filename, track_filename) :
|
||||
track_filename);
|
||||
const std::string track_full_filename(
|
||||
!Path::IsAbsolute(track_filename) ? Path::BuildRelativePath(m_filename, track_filename) : track_filename);
|
||||
std::FILE* track_fp = FileSystem::OpenCFile(track_full_filename.c_str(), "rb");
|
||||
if (!track_fp && track_file_index == 0)
|
||||
{
|
||||
// many users have bad cuesheets, or they're renamed the files without updating the cuesheet.
|
||||
// so, try searching for a bin with the same name as the cue, but only for the first referenced file.
|
||||
const std::string alternative_filename(FileSystem::ReplaceExtension(filename, "bin"));
|
||||
const std::string alternative_filename(Path::ReplaceExtension(filename, "bin"));
|
||||
track_fp = FileSystem::OpenCFile(alternative_filename.c_str(), "rb");
|
||||
if (track_fp)
|
||||
{
|
||||
|
@ -4,10 +4,11 @@
|
||||
#include "error.h"
|
||||
#include "file_system.h"
|
||||
#include "log.h"
|
||||
#include "path.h"
|
||||
#include <algorithm>
|
||||
#include <cerrno>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
Log_SetChannel(CDImageMemory);
|
||||
|
||||
class CDImageM3u : public CDImage
|
||||
@ -88,9 +89,9 @@ bool CDImageM3u::Open(const char* path, Common::Error* error)
|
||||
|
||||
Entry entry;
|
||||
std::string entry_filename(line.begin() + start_offset, line.begin() + end_offset + 1);
|
||||
entry.title = FileSystem::GetFileTitleFromPath(entry_filename);
|
||||
if (!FileSystem::IsAbsolutePath(entry_filename))
|
||||
entry.filename = FileSystem::BuildRelativePath(path, entry_filename);
|
||||
entry.title = Path::GetFileTitle(entry_filename);
|
||||
if (!Path::IsAbsolute(entry_filename))
|
||||
entry.filename = Path::BuildRelativePath(path, entry_filename);
|
||||
else
|
||||
entry.filename = std::move(entry_filename);
|
||||
|
||||
@ -154,7 +155,7 @@ std::string CDImageM3u::GetSubImageMetadata(u32 index, const std::string_view& t
|
||||
if (type == "title")
|
||||
return m_entries[index].title;
|
||||
else if (type == "file_title")
|
||||
return std::string(FileSystem::GetFileTitleFromPath(m_entries[index].filename));
|
||||
return std::string(Path::GetFileTitle(m_entries[index].filename));
|
||||
|
||||
return CDImage::GetSubImageMetadata(index, type);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "error.h"
|
||||
#include "file_system.h"
|
||||
#include "log.h"
|
||||
#include "path.h"
|
||||
#include <algorithm>
|
||||
#include <cerrno>
|
||||
#include <map>
|
||||
@ -80,7 +81,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Common::Error* error)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string mdf_filename(FileSystem::ReplaceExtension(filename, "mdf"));
|
||||
std::string mdf_filename(Path::ReplaceExtension(filename, "mdf"));
|
||||
m_mdf_file = FileSystem::OpenCFile(mdf_filename.c_str(), "rb");
|
||||
if (!m_mdf_file)
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "cd_subchannel_replacement.h"
|
||||
#include "file_system.h"
|
||||
#include "log.h"
|
||||
#include "path.h"
|
||||
#include <algorithm>
|
||||
#include <cerrno>
|
||||
Log_SetChannel(CDImageMemory);
|
||||
@ -109,7 +110,7 @@ bool CDImageMemory::CopyImage(CDImage* image, ProgressCallback* progress)
|
||||
m_filename = image->GetFileName();
|
||||
m_lba_count = image->GetLBACount();
|
||||
|
||||
m_sbi.LoadSBI(FileSystem::ReplaceExtension(m_filename, "sbi").c_str());
|
||||
m_sbi.LoadSBI(Path::ReplaceExtension(m_filename, "sbi").c_str());
|
||||
|
||||
return Seek(1, Position{0, 0, 0});
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "error.h"
|
||||
#include "file_system.h"
|
||||
#include "log.h"
|
||||
#include "path.h"
|
||||
#include "pbp_types.h"
|
||||
#include "string.h"
|
||||
#include "string_util.h"
|
||||
@ -674,12 +675,12 @@ bool CDImagePBP::OpenDisc(u32 index, Common::Error* error)
|
||||
|
||||
if (m_disc_offsets.size() > 1)
|
||||
{
|
||||
std::string sbi_path(FileSystem::StripExtension(m_filename));
|
||||
std::string sbi_path(Path::StripExtension(m_filename));
|
||||
sbi_path += TinyString::FromFormat("_%u.sbi", index + 1);
|
||||
m_sbi.LoadSBI(sbi_path.c_str());
|
||||
}
|
||||
else
|
||||
m_sbi.LoadSBI(FileSystem::ReplaceExtension(m_filename, "sbi").c_str());
|
||||
m_sbi.LoadSBI(Path::ReplaceExtension(m_filename, "sbi").c_str());
|
||||
|
||||
m_current_disc = index;
|
||||
return Seek(1, Position{0, 0, 0});
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "cd_subchannel_replacement.h"
|
||||
#include "file_system.h"
|
||||
#include "log.h"
|
||||
#include "path.h"
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
Log_SetChannel(CDSubChannelReplacement);
|
||||
@ -85,7 +86,7 @@ bool CDSubChannelReplacement::LoadSBI(const char* path)
|
||||
|
||||
bool CDSubChannelReplacement::LoadSBIFromImagePath(const char* image_path)
|
||||
{
|
||||
return LoadSBI(FileSystem::ReplaceExtension(image_path, "sbi").c_str());
|
||||
return LoadSBI(Path::ReplaceExtension(image_path, "sbi").c_str());
|
||||
}
|
||||
|
||||
void CDSubChannelReplacement::AddReplacementSubChannelQ(u32 lba, const CDImage::SubChannelQ& subq)
|
||||
|
@ -34,6 +34,7 @@
|
||||
<ClInclude Include="gl\context_wgl.h">
|
||||
<ExcludedFromBuild Condition="'$(Platform)'=='ARM' Or '$(Platform)'=='ARM64' Or '$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="gl\loader.h" />
|
||||
<ClInclude Include="gl\program.h" />
|
||||
<ClInclude Include="gl\shader_cache.h" />
|
||||
<ClInclude Include="gl\stream_buffer.h" />
|
||||
@ -55,6 +56,7 @@
|
||||
<ClInclude Include="make_array.h" />
|
||||
<ClInclude Include="md5_digest.h" />
|
||||
<ClInclude Include="null_audio_stream.h" />
|
||||
<ClInclude Include="path.h" />
|
||||
<ClInclude Include="pbp_types.h" />
|
||||
<ClInclude Include="platform.h" />
|
||||
<ClInclude Include="progress_callback.h" />
|
||||
@ -71,7 +73,6 @@
|
||||
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="timer.h" />
|
||||
<ClInclude Include="timestamp.h" />
|
||||
<ClInclude Include="types.h" />
|
||||
<ClInclude Include="cd_xa.h" />
|
||||
<ClInclude Include="minizip_helpers.h" />
|
||||
@ -91,6 +92,7 @@
|
||||
<ClInclude Include="win32_progress_callback.h">
|
||||
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="windows_headers.h" />
|
||||
<ClInclude Include="window_info.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -161,7 +163,6 @@
|
||||
<ExcludedFromBuild Condition="'$(BuildingForUWP)'=='true'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="timer.cpp" />
|
||||
<ClCompile Include="timestamp.cpp" />
|
||||
<ClCompile Include="vulkan\builders.cpp" />
|
||||
<ClCompile Include="vulkan\context.cpp" />
|
||||
<ClCompile Include="vulkan\loader.cpp" />
|
||||
|
@ -39,7 +39,6 @@
|
||||
<ClInclude Include="string.h" />
|
||||
<ClInclude Include="byte_stream.h" />
|
||||
<ClInclude Include="timer.h" />
|
||||
<ClInclude Include="timestamp.h" />
|
||||
<ClInclude Include="assert.h" />
|
||||
<ClInclude Include="align.h" />
|
||||
<ClInclude Include="file_system.h" />
|
||||
@ -143,6 +142,11 @@
|
||||
<ClInclude Include="vulkan\loader.h">
|
||||
<Filter>vulkan</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="path.h" />
|
||||
<ClInclude Include="windows_headers.h" />
|
||||
<ClInclude Include="gl\loader.h">
|
||||
<Filter>gl</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="jit_code_buffer.cpp" />
|
||||
@ -179,7 +183,6 @@
|
||||
<ClCompile Include="string.cpp" />
|
||||
<ClCompile Include="byte_stream.cpp" />
|
||||
<ClCompile Include="log.cpp" />
|
||||
<ClCompile Include="timestamp.cpp" />
|
||||
<ClCompile Include="timer.cpp" />
|
||||
<ClCompile Include="assert.cpp" />
|
||||
<ClCompile Include="file_system.cpp" />
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,12 @@
|
||||
#pragma once
|
||||
#include "timestamp.h"
|
||||
#include "types.h"
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sys/stat.h>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define FS_OSPATH_SEPARATOR_CHARACTER '\\'
|
||||
@ -36,177 +35,104 @@ enum FILESYSTEM_FIND_FLAGS
|
||||
|
||||
struct FILESYSTEM_STAT_DATA
|
||||
{
|
||||
std::time_t CreationTime; // actually inode change time on linux
|
||||
std::time_t ModificationTime;
|
||||
s64 Size;
|
||||
u32 Attributes;
|
||||
Timestamp ModificationTime;
|
||||
u64 Size;
|
||||
};
|
||||
|
||||
struct FILESYSTEM_FIND_DATA
|
||||
{
|
||||
std::time_t CreationTime; // actually inode change time on linux
|
||||
std::time_t ModificationTime;
|
||||
std::string FileName;
|
||||
Timestamp ModificationTime;
|
||||
s64 Size;
|
||||
u32 Attributes;
|
||||
u64 Size;
|
||||
};
|
||||
|
||||
struct FILESYSTEM_CHANGE_NOTIFY_DATA
|
||||
{
|
||||
String DirectoryPath;
|
||||
bool RecursiveWatch;
|
||||
|
||||
void* pSystemData;
|
||||
};
|
||||
|
||||
namespace FileSystem {
|
||||
|
||||
using FindResultsArray = std::vector<FILESYSTEM_FIND_DATA>;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
/// Sets the instance for the FileHelpers Java class, used for storage access framework
|
||||
/// file access on Android.
|
||||
void SetAndroidFileHelper(void* jvm, void* env, void* object);
|
||||
#endif
|
||||
|
||||
class ChangeNotifier
|
||||
{
|
||||
public:
|
||||
enum ChangeEvent
|
||||
{
|
||||
ChangeEvent_FileAdded = (1 << 0),
|
||||
ChangeEvent_FileRemoved = (1 << 1),
|
||||
ChangeEvent_FileModified = (1 << 2),
|
||||
ChangeEvent_RenamedOldName = (1 << 3),
|
||||
ChangeEvent_RenamedNewName = (1 << 4),
|
||||
};
|
||||
|
||||
struct ChangeInfo
|
||||
{
|
||||
const char* Path;
|
||||
u32 Event;
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~ChangeNotifier();
|
||||
|
||||
const String& GetDirectoryPath() const { return m_directoryPath; }
|
||||
const bool GetRecursiveWatch() const { return m_recursiveWatch; }
|
||||
|
||||
typedef void (*EnumerateChangesCallback)(const ChangeInfo* pChangeInfo, void* pUserData);
|
||||
virtual void EnumerateChanges(EnumerateChangesCallback callback, void* pUserData) = 0;
|
||||
|
||||
private:
|
||||
template<typename CALLBACK_TYPE>
|
||||
static void EnumerateChangesTrampoline(const ChangeInfo* pChangeInfo, void* pUserData)
|
||||
{
|
||||
CALLBACK_TYPE* pRealCallback = reinterpret_cast<CALLBACK_TYPE*>(pUserData);
|
||||
(*pRealCallback)(pChangeInfo);
|
||||
}
|
||||
|
||||
public:
|
||||
template<typename CALLBACK_TYPE>
|
||||
void EnumerateChanges(CALLBACK_TYPE callback)
|
||||
{
|
||||
CALLBACK_TYPE* pCallback = &callback;
|
||||
EnumerateChanges(&ChangeNotifier::EnumerateChangesTrampoline<CALLBACK_TYPE>, reinterpret_cast<void*>(pCallback));
|
||||
}
|
||||
|
||||
protected:
|
||||
ChangeNotifier(const String& directoryPath, bool recursiveWatch);
|
||||
|
||||
String m_directoryPath;
|
||||
bool m_recursiveWatch;
|
||||
};
|
||||
|
||||
// create a change notifier
|
||||
std::unique_ptr<ChangeNotifier> CreateChangeNotifier(const char* path, bool recursiveWatch);
|
||||
|
||||
// canonicalize a path string (i.e. replace .. with actual folder name, etc), if OS path is used, on windows, the
|
||||
// separators will be \, otherwise /
|
||||
void CanonicalizePath(char* Destination, u32 cbDestination, const char* Path, bool OSPath = true);
|
||||
void CanonicalizePath(String& Destination, const char* Path, bool OSPath = true);
|
||||
void CanonicalizePath(String& Destination, bool OSPath = true);
|
||||
void CanonicalizePath(std::string& path, bool OSPath = true);
|
||||
|
||||
// translates the specified path into a string compatible with the hosting OS
|
||||
void BuildOSPath(char* Destination, u32 cbDestination, const char* Path);
|
||||
void BuildOSPath(String& Destination, const char* Path);
|
||||
void BuildOSPath(String& Destination);
|
||||
|
||||
// builds a path relative to the specified file
|
||||
std::string BuildRelativePath(const std::string_view& filename, const std::string_view& new_filename);
|
||||
|
||||
// sanitizes a filename for use in a filesystem.
|
||||
void SanitizeFileName(char* Destination, u32 cbDestination, const char* FileName, bool StripSlashes = true);
|
||||
void SanitizeFileName(String& Destination, const char* FileName, bool StripSlashes = true);
|
||||
void SanitizeFileName(String& Destination, bool StripSlashes = true);
|
||||
void SanitizeFileName(std::string& Destination, bool StripSlashes = true);
|
||||
|
||||
/// Returns true if the specified path is an absolute path (C:\Path on Windows or /path on Unix).
|
||||
bool IsAbsolutePath(const std::string_view& path);
|
||||
|
||||
/// Removes the extension of a filename.
|
||||
std::string_view StripExtension(const std::string_view& path);
|
||||
|
||||
/// Replaces the extension of a filename with another.
|
||||
std::string ReplaceExtension(const std::string_view& path, const std::string_view& new_extension);
|
||||
|
||||
/// Returns the display name of a filename. Usually this is the same as the path, except on Android
|
||||
/// where it resolves a content URI to its name.
|
||||
/// Returns the display name of a filename. Usually this is the same as the path.
|
||||
std::string GetDisplayNameFromPath(const std::string_view& path);
|
||||
|
||||
/// Returns the directory component of a filename.
|
||||
std::string_view GetPathDirectory(const std::string_view& path);
|
||||
|
||||
/// Returns the filename component of a filename.
|
||||
std::string_view GetFileNameFromPath(const std::string_view& path);
|
||||
|
||||
/// Returns the file title (less the extension and path) from a filename.
|
||||
std::string_view GetFileTitleFromPath(const std::string_view& path);
|
||||
|
||||
/// Returns a list of "root directories" (i.e. root/home directories on Linux, drive letters on Windows).
|
||||
std::vector<std::string> GetRootDirectoryList();
|
||||
|
||||
// search for files
|
||||
bool FindFiles(const char* Path, const char* Pattern, u32 Flags, FindResultsArray* pResults);
|
||||
/// Search for files
|
||||
bool FindFiles(const char* path, const char* pattern, u32 flags, FindResultsArray* results);
|
||||
|
||||
// stat file
|
||||
bool StatFile(const char* Path, FILESYSTEM_STAT_DATA* pStatData);
|
||||
/// Stat file
|
||||
bool StatFile(const char* path, struct stat* st);
|
||||
bool StatFile(std::FILE* fp, struct stat* st);
|
||||
bool StatFile(const char* path, FILESYSTEM_STAT_DATA* pStatData);
|
||||
bool StatFile(std::FILE* fp, FILESYSTEM_STAT_DATA* pStatData);
|
||||
s64 GetPathFileSize(const char* path);
|
||||
|
||||
// file exists?
|
||||
bool FileExists(const char* Path);
|
||||
/// File exists?
|
||||
bool FileExists(const char* path);
|
||||
|
||||
// directory exists?
|
||||
bool DirectoryExists(const char* Path);
|
||||
/// Directory exists?
|
||||
bool DirectoryExists(const char* path);
|
||||
|
||||
// delete file
|
||||
bool DeleteFile(const char* Path);
|
||||
/// Directory does not contain any files?
|
||||
bool DirectoryIsEmpty(const char* path);
|
||||
|
||||
// rename file
|
||||
/// Delete file
|
||||
bool DeleteFile(const char* path);
|
||||
|
||||
/// Rename file
|
||||
bool RenamePath(const char* OldPath, const char* NewPath);
|
||||
|
||||
/// open files
|
||||
using ManagedCFilePtr = std::unique_ptr<std::FILE, void (*)(std::FILE*)>;
|
||||
ManagedCFilePtr OpenManagedCFile(const char* filename, const char* mode);
|
||||
std::FILE* OpenCFile(const char* filename, const char* mode);
|
||||
int FSeek64(std::FILE* fp, s64 offset, int whence);
|
||||
s64 FTell64(std::FILE* fp);
|
||||
s64 FSize64(std::FILE* fp);
|
||||
|
||||
int OpenFDFile(const char* filename, int flags, int mode);
|
||||
|
||||
/// Sharing modes for OpenSharedCFile().
|
||||
enum class FileShareMode
|
||||
{
|
||||
DenyReadWrite, /// Exclusive access.
|
||||
DenyWrite, /// Other processes can read from this file.
|
||||
DenyRead, /// Other processes can write to this file.
|
||||
DenyNone, /// Other processes can read and write to this file.
|
||||
};
|
||||
|
||||
/// Opens a file in shareable mode (where other processes can access it concurrently).
|
||||
/// Only has an effect on Windows systems.
|
||||
ManagedCFilePtr OpenManagedSharedCFile(const char* filename, const char* mode, FileShareMode share_mode);
|
||||
std::FILE* OpenSharedCFile(const char* filename, const char* mode, FileShareMode share_mode);
|
||||
|
||||
std::optional<std::vector<u8>> ReadBinaryFile(const char* filename);
|
||||
std::optional<std::vector<u8>> ReadBinaryFile(std::FILE* fp);
|
||||
std::optional<std::string> ReadFileToString(const char* filename);
|
||||
std::optional<std::string> ReadFileToString(std::FILE* fp);
|
||||
bool WriteBinaryFile(const char* filename, const void* data, size_t data_length);
|
||||
bool WriteFileToString(const char* filename, const std::string_view& sv);
|
||||
bool WriteStringToFile(const char* filename, const std::string_view& sv);
|
||||
|
||||
// creates a directory in the local filesystem
|
||||
// if the directory already exists, the return value will be true.
|
||||
// if Recursive is specified, all parent directories will be created
|
||||
// if they do not exist.
|
||||
bool CreateDirectory(const char* Path, bool Recursive);
|
||||
/// creates a directory in the local filesystem
|
||||
/// if the directory already exists, the return value will be true.
|
||||
/// if Recursive is specified, all parent directories will be created
|
||||
/// if they do not exist.
|
||||
bool CreateDirectory(const char* path, bool recursive);
|
||||
|
||||
// deletes a directory in the local filesystem
|
||||
// if the directory has files, unless the recursive flag is set, it will fail
|
||||
bool DeleteDirectory(const char* Path, bool Recursive);
|
||||
/// Creates a directory if it doesn't already exist.
|
||||
/// Returns false if it does not exist and creation failed.
|
||||
bool EnsureDirectoryExists(const char* path, bool recursive);
|
||||
|
||||
/// Removes a directory.
|
||||
bool DeleteDirectory(const char* path);
|
||||
|
||||
/// Recursively removes a directory and all subdirectories/files.
|
||||
bool RecursiveDeleteDirectory(const char* path);
|
||||
|
||||
/// Copies one file to another, optionally replacing it if it already exists.
|
||||
bool CopyFilePath(const char* source, const char* destination, bool replace);
|
||||
|
||||
/// Returns the path to the current executable.
|
||||
std::string GetProgramPath();
|
||||
@ -217,4 +143,9 @@ std::string GetWorkingDirectory();
|
||||
/// Sets the current working directory. Returns true if successful.
|
||||
bool SetWorkingDirectory(const char* path);
|
||||
|
||||
/// Enables/disables NTFS compression on a file or directory.
|
||||
/// Does not apply the compression flag recursively if called for a directory.
|
||||
/// Does nothing and returns false on non-Windows platforms.
|
||||
bool SetPathCompression(const char* path, bool enable);
|
||||
|
||||
}; // namespace FileSystem
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "context.h"
|
||||
#include "../log.h"
|
||||
#include "glad.h"
|
||||
#include "loader.h"
|
||||
#include <cstdlib>
|
||||
#ifdef __APPLE__
|
||||
#include <stdlib.h>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "context.h"
|
||||
#include <glad.h>
|
||||
#include "loader.h"
|
||||
|
||||
#if defined(__APPLE__) && defined(__OBJC__)
|
||||
#import <AppKit/AppKit.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "context_agl.h"
|
||||
#include "../assert.h"
|
||||
#include "../log.h"
|
||||
#include "glad.h"
|
||||
#include "loader.h"
|
||||
#include <dlfcn.h>
|
||||
Log_SetChannel(GL::ContextAGL);
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "context_wgl.h"
|
||||
#include "../assert.h"
|
||||
#include "../log.h"
|
||||
#include "glad.h"
|
||||
#include "glad_wgl.h"
|
||||
#include "loader.h"
|
||||
Log_SetChannel(GL::ContextWGL);
|
||||
|
||||
// TODO: get rid of this
|
||||
#include "glad_wgl.h"
|
||||
#pragma comment(lib, "opengl32.lib")
|
||||
|
||||
static void* GetProcAddressCallback(const char* name)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "../windows_headers.h"
|
||||
#include "context.h"
|
||||
#include <glad.h>
|
||||
#include "loader.h"
|
||||
|
||||
namespace GL {
|
||||
|
||||
|
8
src/common/gl/loader.h
Normal file
8
src/common/gl/loader.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// Fix glad.h including windows.h
|
||||
#ifdef _WIN32
|
||||
#include "../windows_headers.h"
|
||||
#endif
|
||||
|
||||
#include "glad.h"
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "glad.h"
|
||||
#include "loader.h"
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include <glad.h>
|
||||
#include "loader.h"
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include <glad.h>
|
||||
#include "loader.h"
|
||||
|
||||
namespace GL {
|
||||
class Texture
|
||||
|
68
src/common/path.h
Normal file
68
src/common/path.h
Normal file
@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace Path {
|
||||
/// Converts any forward slashes to backslashes on Win32.
|
||||
std::string ToNativePath(const std::string_view& path);
|
||||
void ToNativePath(std::string* path);
|
||||
|
||||
/// Builds a path relative to the specified file
|
||||
std::string BuildRelativePath(const std::string_view& filename, const std::string_view& new_filename);
|
||||
|
||||
/// Joins path components together, producing a new path.
|
||||
std::string Combine(const std::string_view& base, const std::string_view& next);
|
||||
|
||||
/// Removes all .. and . components from a path.
|
||||
std::string Canonicalize(const std::string_view& path);
|
||||
void Canonicalize(std::string* path);
|
||||
|
||||
/// Sanitizes a filename for use in a filesystem.
|
||||
void SanitizeFileName(char* Destination, u32 cbDestination, const char* FileName, bool StripSlashes /* = true */);
|
||||
void SanitizeFileName(std::string& Destination, bool StripSlashes = true);
|
||||
|
||||
/// Returns true if the specified path is an absolute path (C:\Path on Windows or /path on Unix).
|
||||
bool IsAbsolute(const std::string_view& path);
|
||||
|
||||
/// Makes the specified path relative to another (e.g. /a/b/c, /a/b -> ../c).
|
||||
/// Both paths must be relative, otherwise this function will just return the input path.
|
||||
std::string MakeRelative(const std::string_view& path, const std::string_view& relative_to);
|
||||
|
||||
/// Returns a view of the extension of a filename.
|
||||
std::string_view GetExtension(const std::string_view& path);
|
||||
|
||||
/// Removes the extension of a filename.
|
||||
std::string_view StripExtension(const std::string_view& path);
|
||||
|
||||
/// Replaces the extension of a filename with another.
|
||||
std::string ReplaceExtension(const std::string_view& path, const std::string_view& new_extension);
|
||||
|
||||
/// Returns the directory component of a filename.
|
||||
std::string_view GetDirectory(const std::string_view& path);
|
||||
|
||||
/// Returns the filename component of a filename.
|
||||
std::string_view GetFileName(const std::string_view& path);
|
||||
|
||||
/// Returns the file title (less the extension and path) from a filename.
|
||||
std::string_view GetFileTitle(const std::string_view& path);
|
||||
|
||||
/// Changes the filename in a path.
|
||||
std::string ChangeFileName(const std::string_view& path, const std::string_view& new_filename);
|
||||
void ChangeFileName(std::string* path, const std::string_view& new_filename);
|
||||
|
||||
/// Appends a directory to a path.
|
||||
std::string AppendDirectory(const std::string_view& path, const std::string_view& new_dir);
|
||||
void AppendDirectory(std::string* path, const std::string_view& new_dir);
|
||||
|
||||
/// Splits a path into its components, handling both Windows and Unix separators.
|
||||
std::vector<std::string_view> SplitWindowsPath(const std::string_view& path);
|
||||
std::string JoinWindowsPath(const std::vector<std::string_view>& components);
|
||||
|
||||
/// Splits a path into its components, only handling native separators.
|
||||
std::vector<std::string_view> SplitNativePath(const std::string_view& path);
|
||||
std::string JoinNativePath(const std::vector<std::string_view>& components);
|
||||
} // namespace Path
|
@ -1,331 +0,0 @@
|
||||
#include "timestamp.h"
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <tuple>
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
static void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst);
|
||||
static time_t SystemTimeToUnixTime(const SYSTEMTIME* pst);
|
||||
|
||||
#endif
|
||||
|
||||
Timestamp::Timestamp()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
m_value.wYear = 1970;
|
||||
m_value.wMonth = 1;
|
||||
m_value.wDayOfWeek = 0;
|
||||
m_value.wDay = 1;
|
||||
m_value.wHour = 0;
|
||||
m_value.wMinute = 0;
|
||||
m_value.wSecond = 0;
|
||||
m_value.wMilliseconds = 0;
|
||||
#else
|
||||
m_value.tv_sec = 0;
|
||||
m_value.tv_usec = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
Timestamp::Timestamp(const Timestamp& copy)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
std::memcpy(&m_value, ©.m_value, sizeof(m_value));
|
||||
#else
|
||||
std::memcpy(&m_value, ©.m_value, sizeof(m_value));
|
||||
#endif
|
||||
}
|
||||
|
||||
double Timestamp::DifferenceInSeconds(Timestamp& other) const
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
FILETIME lft, rft;
|
||||
SystemTimeToFileTime(&m_value, &lft);
|
||||
SystemTimeToFileTime(&other.m_value, &rft);
|
||||
|
||||
u64 lval = ((u64)lft.dwHighDateTime) << 32 | (u64)lft.dwLowDateTime;
|
||||
u64 rval = ((u64)rft.dwHighDateTime) << 32 | (u64)rft.dwLowDateTime;
|
||||
s64 diff = ((s64)lval - (s64)rval);
|
||||
return double(diff / 10000000ULL) + (double(diff % 10000000ULL) / 10000000.0);
|
||||
|
||||
#else
|
||||
return (double)(m_value.tv_sec - other.m_value.tv_sec) +
|
||||
(((double)(m_value.tv_usec - other.m_value.tv_usec)) / 1000000.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
s64 Timestamp::DifferenceInSecondsInt(Timestamp& other) const
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
FILETIME lft, rft;
|
||||
SystemTimeToFileTime(&m_value, &lft);
|
||||
SystemTimeToFileTime(&other.m_value, &rft);
|
||||
|
||||
u64 lval = ((u64)lft.dwHighDateTime) << 32 | (u64)lft.dwLowDateTime;
|
||||
u64 rval = ((u64)rft.dwHighDateTime) << 32 | (u64)rft.dwLowDateTime;
|
||||
s64 diff = ((s64)lval - (s64)rval);
|
||||
return diff / 10000000ULL;
|
||||
|
||||
#else
|
||||
return static_cast<s64>(m_value.tv_sec - other.m_value.tv_sec);
|
||||
#endif
|
||||
}
|
||||
|
||||
Timestamp::UnixTimestampValue Timestamp::AsUnixTimestamp() const
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return (UnixTimestampValue)SystemTimeToUnixTime(&m_value);
|
||||
#else
|
||||
return (UnixTimestampValue)m_value.tv_sec;
|
||||
#endif
|
||||
}
|
||||
|
||||
Timestamp::ExpandedTime Timestamp::AsExpandedTime() const
|
||||
{
|
||||
ExpandedTime et;
|
||||
|
||||
#if defined(_WIN32)
|
||||
et.Year = m_value.wYear;
|
||||
et.Month = m_value.wMonth;
|
||||
et.DayOfMonth = m_value.wDay;
|
||||
et.DayOfWeek = m_value.wDayOfWeek;
|
||||
et.Hour = m_value.wHour;
|
||||
et.Minute = m_value.wMinute;
|
||||
et.Second = m_value.wSecond;
|
||||
et.Milliseconds = m_value.wMilliseconds;
|
||||
#else
|
||||
struct tm t;
|
||||
time_t unixTime = (time_t)m_value.tv_sec;
|
||||
gmtime_r(&unixTime, &t);
|
||||
et.Year = t.tm_year + 1900;
|
||||
et.Month = t.tm_mon + 1;
|
||||
et.DayOfMonth = t.tm_mday;
|
||||
et.DayOfWeek = t.tm_wday;
|
||||
et.Hour = t.tm_hour;
|
||||
et.Minute = t.tm_min;
|
||||
et.Second = t.tm_sec;
|
||||
et.Milliseconds = m_value.tv_usec / 1000;
|
||||
#endif
|
||||
|
||||
return et;
|
||||
}
|
||||
|
||||
void Timestamp::SetNow()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
GetSystemTime(&m_value);
|
||||
#else
|
||||
gettimeofday(&m_value, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Timestamp::SetUnixTimestamp(UnixTimestampValue value)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
UnixTimeToSystemTime((time_t)value, &m_value);
|
||||
#else
|
||||
m_value.tv_sec = (time_t)value;
|
||||
m_value.tv_usec = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Timestamp::SetExpandedTime(const ExpandedTime& value)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
// bit of a hacky way to fill in the missing fields
|
||||
SYSTEMTIME st;
|
||||
st.wYear = (WORD)value.Year;
|
||||
st.wMonth = (WORD)value.Month;
|
||||
st.wDay = (WORD)value.DayOfMonth;
|
||||
st.wDayOfWeek = (WORD)0;
|
||||
st.wHour = (WORD)value.Hour;
|
||||
st.wMinute = (WORD)value.Minute;
|
||||
st.wSecond = (WORD)value.Second;
|
||||
st.wMilliseconds = (WORD)value.Milliseconds;
|
||||
FILETIME ft;
|
||||
SystemTimeToFileTime(&st, &ft);
|
||||
FileTimeToSystemTime(&ft, &m_value);
|
||||
#else
|
||||
struct tm t;
|
||||
std::memset(&t, 0, sizeof(t));
|
||||
t.tm_sec = value.Second;
|
||||
t.tm_min = value.Minute;
|
||||
t.tm_hour = value.Hour;
|
||||
t.tm_mday = value.DayOfMonth;
|
||||
t.tm_mon = value.Month - 1;
|
||||
t.tm_year = value.Year - 1900;
|
||||
time_t unixTime = mktime(&t);
|
||||
SetUnixTimestamp((UnixTimestampValue)unixTime);
|
||||
#endif
|
||||
}
|
||||
|
||||
String Timestamp::ToString(const char* format) const
|
||||
{
|
||||
SmallString destination;
|
||||
ToString(destination, format);
|
||||
return String(destination);
|
||||
}
|
||||
|
||||
void Timestamp::ToString(String& destination, const char* format) const
|
||||
{
|
||||
time_t unixTime = (time_t)AsUnixTimestamp();
|
||||
tm localTime;
|
||||
|
||||
#if defined(_WIN32)
|
||||
localtime_s(&localTime, &unixTime);
|
||||
#else
|
||||
localtime_r(&unixTime, &localTime);
|
||||
#endif
|
||||
|
||||
char buffer[256];
|
||||
strftime(buffer, countof(buffer) - 1, format, &localTime);
|
||||
buffer[countof(buffer) - 1] = 0;
|
||||
|
||||
destination.Clear();
|
||||
destination.AppendString(buffer);
|
||||
}
|
||||
|
||||
Timestamp Timestamp::Now()
|
||||
{
|
||||
Timestamp t;
|
||||
t.SetNow();
|
||||
return t;
|
||||
}
|
||||
|
||||
Timestamp Timestamp::FromUnixTimestamp(UnixTimestampValue value)
|
||||
{
|
||||
Timestamp t;
|
||||
t.SetUnixTimestamp(value);
|
||||
return t;
|
||||
}
|
||||
|
||||
Timestamp Timestamp::FromExpandedTime(const ExpandedTime& value)
|
||||
{
|
||||
Timestamp t;
|
||||
t.SetExpandedTime(value);
|
||||
return t;
|
||||
}
|
||||
|
||||
bool Timestamp::operator==(const Timestamp& other) const
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return std::memcmp(&m_value, &other.m_value, sizeof(m_value)) == 0;
|
||||
#else
|
||||
return std::memcmp(&m_value, &other.m_value, sizeof(m_value)) == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Timestamp::operator!=(const Timestamp& other) const
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
bool Timestamp::operator<(const Timestamp& other) const
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return std::tie(m_value.wYear, m_value.wMonth, m_value.wDay, m_value.wHour, m_value.wMinute, m_value.wSecond,
|
||||
m_value.wMilliseconds) < std::tie(other.m_value.wYear, other.m_value.wMonth, other.m_value.wDay,
|
||||
other.m_value.wHour, other.m_value.wMinute, other.m_value.wSecond,
|
||||
other.m_value.wMilliseconds);
|
||||
#else
|
||||
return std::tie(m_value.tv_sec, m_value.tv_usec) < std::tie(other.m_value.tv_sec, other.m_value.tv_usec);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Timestamp::operator<=(const Timestamp& other) const
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return std::tie(m_value.wYear, m_value.wMonth, m_value.wDay, m_value.wHour, m_value.wMinute, m_value.wSecond,
|
||||
m_value.wMilliseconds) <= std::tie(other.m_value.wYear, other.m_value.wMonth, other.m_value.wDay,
|
||||
other.m_value.wHour, other.m_value.wMinute, other.m_value.wSecond,
|
||||
other.m_value.wMilliseconds);
|
||||
#else
|
||||
return std::tie(m_value.tv_sec, m_value.tv_usec) <= std::tie(other.m_value.tv_sec, other.m_value.tv_usec);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Timestamp::operator>(const Timestamp& other) const
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return std::tie(m_value.wYear, m_value.wMonth, m_value.wDay, m_value.wHour, m_value.wMinute, m_value.wSecond,
|
||||
m_value.wMilliseconds) > std::tie(other.m_value.wYear, other.m_value.wMonth, other.m_value.wDay,
|
||||
other.m_value.wHour, other.m_value.wMinute, other.m_value.wSecond,
|
||||
other.m_value.wMilliseconds);
|
||||
#else
|
||||
return std::tie(m_value.tv_sec, m_value.tv_usec) > std::tie(other.m_value.tv_sec, other.m_value.tv_usec);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Timestamp::operator>=(const Timestamp& other) const
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return std::tie(m_value.wYear, m_value.wMonth, m_value.wDay, m_value.wHour, m_value.wMinute, m_value.wSecond,
|
||||
m_value.wMilliseconds) >= std::tie(other.m_value.wYear, other.m_value.wMonth, other.m_value.wDay,
|
||||
other.m_value.wHour, other.m_value.wMinute, other.m_value.wSecond,
|
||||
other.m_value.wMilliseconds);
|
||||
#else
|
||||
return std::tie(m_value.tv_sec, m_value.tv_usec) >= std::tie(other.m_value.tv_sec, other.m_value.tv_usec);
|
||||
#endif
|
||||
}
|
||||
|
||||
Timestamp& Timestamp::operator=(const Timestamp& other)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
std::memcpy(&m_value, &other.m_value, sizeof(m_value));
|
||||
#else
|
||||
std::memcpy(&m_value, &other.m_value, sizeof(m_value));
|
||||
#endif
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/sysinfo/converting-a-time-t-value-to-a-file-time
|
||||
static void UnixTimeToFileTime(time_t t, LPFILETIME pft)
|
||||
{
|
||||
ULARGE_INTEGER time_value;
|
||||
time_value.QuadPart = (t * 10000000LL) + 116444736000000000LL;
|
||||
pft->dwLowDateTime = time_value.LowPart;
|
||||
pft->dwHighDateTime = time_value.HighPart;
|
||||
}
|
||||
static void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
|
||||
{
|
||||
FILETIME ft;
|
||||
UnixTimeToFileTime(t, &ft);
|
||||
FileTimeToSystemTime(&ft, pst);
|
||||
}
|
||||
static time_t FileTimeToUnixTime(const FILETIME* pft)
|
||||
{
|
||||
LONGLONG ll = ((LONGLONG)pft->dwHighDateTime) << 32 | (LONGLONG)pft->dwLowDateTime;
|
||||
ll -= 116444736000000000ULL;
|
||||
ll /= 10000000ULL;
|
||||
return (time_t)ll;
|
||||
}
|
||||
static time_t SystemTimeToUnixTime(const SYSTEMTIME* pst)
|
||||
{
|
||||
FILETIME ft;
|
||||
SystemTimeToFileTime(pst, &ft);
|
||||
return FileTimeToUnixTime(&ft);
|
||||
}
|
||||
|
||||
FILETIME Timestamp::AsFileTime()
|
||||
{
|
||||
FILETIME ft;
|
||||
SystemTimeToFileTime(&m_value, &ft);
|
||||
return ft;
|
||||
}
|
||||
|
||||
void Timestamp::SetWindowsFileTime(const FILETIME* pFileTime)
|
||||
{
|
||||
FileTimeToSystemTime(pFileTime, &m_value);
|
||||
}
|
||||
|
||||
Timestamp Timestamp::FromWindowsFileTime(const FILETIME* pFileTime)
|
||||
{
|
||||
Timestamp ts;
|
||||
ts.SetWindowsFileTime(pFileTime);
|
||||
return ts;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,75 +0,0 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
#include "string.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include "windows_headers.h"
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
class Timestamp
|
||||
{
|
||||
public:
|
||||
using UnixTimestampValue = u64;
|
||||
struct ExpandedTime
|
||||
{
|
||||
u32 Year; // 0-...
|
||||
u32 Month; // 1-12
|
||||
u32 DayOfMonth; // 1-31
|
||||
u32 DayOfWeek; // 0-6, starting at Sunday
|
||||
u32 Hour; // 0-23
|
||||
u32 Minute; // 0-59
|
||||
u32 Second; // 0-59
|
||||
u32 Milliseconds; // 0-999
|
||||
};
|
||||
|
||||
public:
|
||||
Timestamp();
|
||||
Timestamp(const Timestamp& copy);
|
||||
|
||||
// readers
|
||||
UnixTimestampValue AsUnixTimestamp() const;
|
||||
ExpandedTime AsExpandedTime() const;
|
||||
|
||||
// calculators
|
||||
double DifferenceInSeconds(Timestamp& other) const;
|
||||
s64 DifferenceInSecondsInt(Timestamp& other) const;
|
||||
|
||||
// setters
|
||||
void SetNow();
|
||||
void SetUnixTimestamp(UnixTimestampValue value);
|
||||
void SetExpandedTime(const ExpandedTime& value);
|
||||
|
||||
// string conversion
|
||||
String ToString(const char* format) const;
|
||||
void ToString(String& destination, const char* format) const;
|
||||
|
||||
// creators
|
||||
static Timestamp Now();
|
||||
static Timestamp FromUnixTimestamp(UnixTimestampValue value);
|
||||
static Timestamp FromExpandedTime(const ExpandedTime& value);
|
||||
|
||||
// windows-specific
|
||||
#ifdef _WIN32
|
||||
FILETIME AsFileTime();
|
||||
void SetWindowsFileTime(const FILETIME* pFileTime);
|
||||
static Timestamp FromWindowsFileTime(const FILETIME* pFileTime);
|
||||
#endif
|
||||
|
||||
// operators
|
||||
bool operator==(const Timestamp& other) const;
|
||||
bool operator!=(const Timestamp& other) const;
|
||||
bool operator<(const Timestamp& other) const;
|
||||
bool operator<=(const Timestamp& other) const;
|
||||
bool operator>(const Timestamp& other) const;
|
||||
bool operator>=(const Timestamp& other) const;
|
||||
Timestamp& operator=(const Timestamp& other);
|
||||
|
||||
private:
|
||||
#if defined(_WIN32)
|
||||
SYSTEMTIME m_value;
|
||||
#else
|
||||
struct timeval m_value;
|
||||
#endif
|
||||
};
|
@ -356,7 +356,7 @@ bool ShaderCache::FlushPipelineCache()
|
||||
|
||||
// Save disk writes if it hasn't changed, think of the poor SSDs.
|
||||
FILESYSTEM_STAT_DATA sd;
|
||||
if (!FileSystem::StatFile(m_pipeline_cache_filename.c_str(), &sd) || sd.Size != static_cast<u64>(data_size))
|
||||
if (!FileSystem::StatFile(m_pipeline_cache_filename.c_str(), &sd) || sd.Size != static_cast<s64>(data_size))
|
||||
{
|
||||
Log_InfoPrintf("Writing %zu bytes to '%s'", data_size, m_pipeline_cache_filename.c_str());
|
||||
if (!FileSystem::WriteBinaryFile(m_pipeline_cache_filename.c_str(), data.data(), data.size()))
|
||||
|
Reference in New Issue
Block a user