[Kernel] Added Support For: XFileRenameInformation
This commit is contained in:
@@ -40,6 +40,10 @@ class HostPathDevice : public Device {
|
||||
uint32_t sectors_per_allocation_unit() const override { return 1; }
|
||||
uint32_t bytes_per_sector() const override { return 0x200; }
|
||||
|
||||
protected:
|
||||
friend class HostPathEntry;
|
||||
std::filesystem::path host_path() const { return host_path_; }
|
||||
|
||||
private:
|
||||
void PopulateEntry(HostPathEntry* parent_entry);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "xenia/base/math.h"
|
||||
#include "xenia/base/string.h"
|
||||
#include "xenia/vfs/device.h"
|
||||
#include "xenia/vfs/devices/host_path_device.h"
|
||||
#include "xenia/vfs/devices/host_path_file.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -110,6 +111,15 @@ bool HostPathEntry::DeleteEntryInternal(Entry* entry) {
|
||||
}
|
||||
}
|
||||
|
||||
void HostPathEntry::RenameEntryInternal(const std::filesystem::path file_path) {
|
||||
const std::string new_host_path_ = xe::utf8::join_paths(
|
||||
xe::path_to_utf8(((HostPathDevice*)device_)->host_path()),
|
||||
xe::path_to_utf8(file_path));
|
||||
|
||||
std::filesystem::rename(host_path_, new_host_path_);
|
||||
host_path_ = new_host_path_;
|
||||
}
|
||||
|
||||
void HostPathEntry::update() {
|
||||
xe::filesystem::FileInfo file_info;
|
||||
if (!xe::filesystem::GetInfo(host_path_, &file_info)) {
|
||||
|
||||
@@ -46,6 +46,7 @@ class HostPathEntry : public Entry {
|
||||
std::unique_ptr<Entry> CreateEntryInternal(const std::string_view name,
|
||||
uint32_t attributes) override;
|
||||
bool DeleteEntryInternal(Entry* entry) override;
|
||||
void RenameEntryInternal(const std::filesystem::path file_path) override;
|
||||
|
||||
std::filesystem::path host_path_;
|
||||
};
|
||||
|
||||
@@ -133,5 +133,22 @@ void Entry::Touch() {
|
||||
// TODO(benvanik): update timestamps.
|
||||
}
|
||||
|
||||
void Entry::Rename(const std::filesystem::path file_path) {
|
||||
std::vector<std::string_view> splitted_path =
|
||||
xe::utf8::split_path(xe::path_to_utf8(file_path));
|
||||
|
||||
splitted_path.erase(splitted_path.begin());
|
||||
|
||||
const std::string guest_path_without_root =
|
||||
xe::utf8::join_guest_paths(splitted_path);
|
||||
|
||||
RenameEntryInternal(guest_path_without_root);
|
||||
|
||||
absolute_path_ = xe::utf8::join_guest_paths(device_->mount_path(),
|
||||
guest_path_without_root);
|
||||
path_ = guest_path_without_root;
|
||||
name_ = xe::path_to_utf8(file_path.filename());
|
||||
}
|
||||
|
||||
} // namespace vfs
|
||||
} // namespace xe
|
||||
|
||||
@@ -111,6 +111,7 @@ class Entry {
|
||||
bool Delete();
|
||||
void Touch();
|
||||
|
||||
void Rename(const std::filesystem::path file_path);
|
||||
// If successful, out_file points to a new file. When finished, call
|
||||
// file->Destroy()
|
||||
virtual X_STATUS Open(uint32_t desired_access, File** out_file) = 0;
|
||||
@@ -131,6 +132,7 @@ class Entry {
|
||||
return nullptr;
|
||||
}
|
||||
virtual bool DeleteEntryInternal(Entry* entry) { return false; }
|
||||
virtual void RenameEntryInternal(const std::filesystem::path file_path) {}
|
||||
|
||||
xe::global_critical_region global_critical_region_;
|
||||
Device* device_;
|
||||
|
||||
@@ -45,6 +45,9 @@ class File {
|
||||
}
|
||||
|
||||
virtual X_STATUS SetLength(size_t length) { return X_STATUS_NOT_IMPLEMENTED; }
|
||||
virtual X_STATUS Rename(const std::filesystem::path file_path) {
|
||||
return X_STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// xe::filesystem::FileAccess
|
||||
uint32_t file_access() const { return file_access_; }
|
||||
|
||||
Reference in New Issue
Block a user