[GPU] Add FXAA post-processing [UI] Add FidelityFX FSR and CAS post-processing [UI] Add blue noise dithering from 10bpc to 8bpc [GPU] Apply the DC PWL gamma ramp closer to the spec, supporting fully white color [UI] Allow the GPU CP thread to present on the host directly, bypassing the UI thread OS paint event [UI] Allow variable refresh rate (or tearing) [UI] Present the newest frame (restart) on DXGI [UI] Replace GraphicsContext with a far more advanced Presenter with more coherent surface connection and UI overlay state management [UI] Connect presentation to windows via the Surface class, not native window handles [Vulkan] Switch to simpler Vulkan setup with no instance/device separation due to interdependencies and to pass fewer objects around [Vulkan] Lower the minimum required Vulkan version to 1.0 [UI/GPU] Various cleanup, mainly ComPtr usage [UI] Support per-monitor DPI awareness v2 on Windows [UI] DPI-scale Dear ImGui [UI] Replace the remaining non-detachable window delegates with unified window event and input listeners [UI] Allow listeners to safely destroy or close the window, and to register/unregister listeners without use-after-free and the ABA problem [UI] Explicit Z ordering of input listeners and UI overlays, top-down for input, bottom-up for drawing [UI] Add explicit window lifecycle phases [UI] Replace Window virtual functions with explicit desired state, its application, actual state, its feedback [UI] GTK: Apply the initial size to the drawing area [UI] Limit internal UI frame rate to that of the monitor [UI] Hide the cursor using a timer instead of polling due to no repeated UI thread paints with GPU CP thread presentation, and only within the window
129 lines
4.3 KiB
C++
129 lines
4.3 KiB
C++
/**
|
|
******************************************************************************
|
|
* Xenia : Xbox 360 Emulator Research Project *
|
|
******************************************************************************
|
|
* Copyright 2022 Ben Vanik. All rights reserved. *
|
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
|
******************************************************************************
|
|
*/
|
|
|
|
#ifndef XENIA_BASE_FILESYSTEM_H_
|
|
#define XENIA_BASE_FILESYSTEM_H_
|
|
|
|
#include <filesystem>
|
|
#include <iterator>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "xenia/base/string.h"
|
|
|
|
namespace xe {
|
|
|
|
std::string path_to_utf8(const std::filesystem::path& path);
|
|
std::u16string path_to_utf16(const std::filesystem::path& path);
|
|
std::filesystem::path to_path(const std::string_view source);
|
|
std::filesystem::path to_path(const std::u16string_view source);
|
|
|
|
namespace filesystem {
|
|
|
|
// Get executable path.
|
|
std::filesystem::path GetExecutablePath();
|
|
|
|
// Get executable folder.
|
|
std::filesystem::path GetExecutableFolder();
|
|
|
|
// Get user folder.
|
|
std::filesystem::path GetUserFolder();
|
|
|
|
// Creates the parent folder of the specified path if needed.
|
|
// This can be used to ensure the destination path for a new file exists before
|
|
// attempting to create it.
|
|
bool CreateParentFolder(const std::filesystem::path& path);
|
|
|
|
// Creates an empty file at the given path, overwriting if it exists.
|
|
bool CreateEmptyFile(const std::filesystem::path& path);
|
|
|
|
// Opens the file at the given path with the specified mode.
|
|
// This behaves like fopen and the returned handle can be used with stdio.
|
|
FILE* OpenFile(const std::filesystem::path& path, const std::string_view mode);
|
|
|
|
// Wrapper for the 64-bit version of fseek, returns true on success.
|
|
bool Seek(FILE* file, int64_t offset, int origin);
|
|
|
|
// Wrapper for the 64-bit version of ftell, returns a positive value on success.
|
|
int64_t Tell(FILE* file);
|
|
|
|
// Reduces the size of a stdio file opened for writing. The file pointer is
|
|
// clamped. If this returns false, the size of the file and the file pointer are
|
|
// undefined.
|
|
bool TruncateStdioFile(FILE* file, uint64_t length);
|
|
|
|
struct FileAccess {
|
|
// Implies kFileReadData.
|
|
static const uint32_t kGenericRead = 0x80000000;
|
|
// Implies kFileWriteData.
|
|
static const uint32_t kGenericWrite = 0x40000000;
|
|
static const uint32_t kGenericExecute = 0x20000000;
|
|
static const uint32_t kGenericAll = 0x10000000;
|
|
static const uint32_t kFileReadData = 0x00000001;
|
|
static const uint32_t kFileWriteData = 0x00000002;
|
|
static const uint32_t kFileAppendData = 0x00000004;
|
|
};
|
|
|
|
class FileHandle {
|
|
public:
|
|
// Opens the file, failing if it doesn't exist.
|
|
// The desired_access bitmask denotes the permissions on the file.
|
|
static std::unique_ptr<FileHandle> OpenExisting(
|
|
const std::filesystem::path& path, uint32_t desired_access);
|
|
|
|
virtual ~FileHandle() = default;
|
|
|
|
const std::filesystem::path& path() const { return path_; }
|
|
|
|
// Reads the requested number of bytes from the file starting at the given
|
|
// offset. The total number of bytes read is returned only if the complete
|
|
// read succeeds.
|
|
virtual bool Read(size_t file_offset, void* buffer, size_t buffer_length,
|
|
size_t* out_bytes_read) = 0;
|
|
|
|
// Writes the given buffer to the file starting at the given offset.
|
|
// The total number of bytes written is returned only if the complete
|
|
// write succeeds.
|
|
virtual bool Write(size_t file_offset, const void* buffer,
|
|
size_t buffer_length, size_t* out_bytes_written) = 0;
|
|
|
|
// Set length of the file in bytes.
|
|
virtual bool SetLength(size_t length) = 0;
|
|
|
|
// Flushes any pending write buffers to the underlying filesystem.
|
|
virtual void Flush() = 0;
|
|
|
|
protected:
|
|
explicit FileHandle(const std::filesystem::path& path) : path_(path) {}
|
|
|
|
std::filesystem::path path_;
|
|
};
|
|
|
|
struct FileInfo {
|
|
enum class Type {
|
|
kFile,
|
|
kDirectory,
|
|
};
|
|
Type type;
|
|
std::filesystem::path name;
|
|
std::filesystem::path path;
|
|
size_t total_size;
|
|
uint64_t create_timestamp;
|
|
uint64_t access_timestamp;
|
|
uint64_t write_timestamp;
|
|
};
|
|
bool GetInfo(const std::filesystem::path& path, FileInfo* out_info);
|
|
std::vector<FileInfo> ListFiles(const std::filesystem::path& path);
|
|
|
|
} // namespace filesystem
|
|
} // namespace xe
|
|
|
|
#endif // XENIA_BASE_FILESYSTEM_H_
|