[VFS] Change file attributes or timestamps.
Changing these options is only viable for r/w mounted host devices (Cache) Changing attributes works only on windows Changing timestamps is mocked and logged to see if there is any title that uses it
This commit is contained in:
parent
c68b09d717
commit
49584ff664
|
@ -128,6 +128,8 @@ std::vector<FileInfo> ListDirectories(const std::filesystem::path& path);
|
|||
std::vector<FileInfo> FilterByName(const std::vector<FileInfo>& files,
|
||||
const std::regex pattern);
|
||||
|
||||
bool SetAttributes(const std::filesystem::path& path, uint64_t attributes);
|
||||
|
||||
#if XE_PLATFORM_ANDROID
|
||||
void AndroidInitialize();
|
||||
void AndroidShutdown();
|
||||
|
|
|
@ -274,5 +274,9 @@ int OpenAndroidContentFileDescriptor(const std::string_view uri,
|
|||
return file_descriptor;
|
||||
}
|
||||
|
||||
bool SetAttributes(const std::filesystem::path& path, uint64_t attributes) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace xe
|
||||
|
|
|
@ -243,5 +243,9 @@ std::vector<FileInfo> ListFiles(const std::filesystem::path& path) {
|
|||
return result;
|
||||
}
|
||||
|
||||
bool SetAttributes(const std::filesystem::path& path, uint64_t attributes) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace xe
|
||||
|
|
|
@ -285,5 +285,9 @@ std::vector<FileInfo> FilterByName(const std::vector<FileInfo>& files,
|
|||
return filtered_entries;
|
||||
}
|
||||
|
||||
bool SetAttributes(const std::filesystem::path& path, uint64_t attributes) {
|
||||
return SetFileAttributes(path.c_str(), static_cast<DWORD>(attributes));
|
||||
}
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace xe
|
||||
|
|
|
@ -207,6 +207,26 @@ dword_result_t NtSetInformationFile_entry(
|
|||
switch (info_class) {
|
||||
case XFileBasicInformation: {
|
||||
auto info = info_ptr.as<X_FILE_BASIC_INFORMATION*>();
|
||||
|
||||
bool basic_result = true;
|
||||
if (info->creation_time) {
|
||||
basic_result &= file->entry()->SetCreateTimestamp(info->creation_time);
|
||||
}
|
||||
|
||||
if (info->last_access_time) {
|
||||
basic_result &=
|
||||
file->entry()->SetAccessTimestamp(info->last_access_time);
|
||||
}
|
||||
|
||||
if (info->last_write_time) {
|
||||
basic_result &= file->entry()->SetWriteTimestamp(info->last_write_time);
|
||||
}
|
||||
|
||||
basic_result &= file->entry()->SetAttributes(info->attributes);
|
||||
if (!basic_result) {
|
||||
result = X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
out_length = sizeof(*info);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -132,5 +132,47 @@ void HostPathEntry::update() {
|
|||
}
|
||||
}
|
||||
|
||||
bool HostPathEntry::SetAttributes(uint64_t attributes) {
|
||||
if (device_->is_read_only()) {
|
||||
return false;
|
||||
}
|
||||
return xe::filesystem::SetAttributes(host_path_, attributes);
|
||||
}
|
||||
|
||||
bool HostPathEntry::SetCreateTimestamp(uint64_t timestamp) {
|
||||
if (device_->is_read_only()) {
|
||||
XELOGW(
|
||||
"{} - Tried to change read-only creation timestamp for file: {} to: {}",
|
||||
__FUNCTION__, name_, timestamp);
|
||||
return false;
|
||||
}
|
||||
XELOGI("{} - Tried to change creation timestamp for file: {} to: {}",
|
||||
__FUNCTION__, name_, timestamp);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HostPathEntry::SetAccessTimestamp(uint64_t timestamp) {
|
||||
if (device_->is_read_only()) {
|
||||
XELOGW(
|
||||
"{} - Tried to change read-only access timestamp for file: {} to: {}",
|
||||
__FUNCTION__, name_, timestamp);
|
||||
return false;
|
||||
}
|
||||
XELOGI("{} - Tried to change access timestamp for file: {} to: {}",
|
||||
__FUNCTION__, name_, timestamp);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HostPathEntry::SetWriteTimestamp(uint64_t timestamp) {
|
||||
if (device_->is_read_only()) {
|
||||
XELOGW("{} - Tried to change read-only write timestamp for file: {} to: {}",
|
||||
__FUNCTION__, name_, timestamp);
|
||||
return false;
|
||||
}
|
||||
XELOGI("{} - Tried to change write timestamp for file: {} to: {}",
|
||||
__FUNCTION__, name_, timestamp);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace vfs
|
||||
} // namespace xe
|
||||
|
|
|
@ -40,6 +40,11 @@ class HostPathEntry : public Entry {
|
|||
size_t length) override;
|
||||
void update() override;
|
||||
|
||||
bool SetAttributes(uint64_t attributes) override;
|
||||
bool SetCreateTimestamp(uint64_t timestamp) override;
|
||||
bool SetAccessTimestamp(uint64_t timestamp) override;
|
||||
bool SetWriteTimestamp(uint64_t timestamp) override;
|
||||
|
||||
private:
|
||||
friend class HostPathDevice;
|
||||
|
||||
|
|
|
@ -94,6 +94,11 @@ class Entry {
|
|||
uint64_t access_timestamp() const { return access_timestamp_; }
|
||||
uint64_t write_timestamp() const { return write_timestamp_; }
|
||||
|
||||
virtual bool SetAttributes(uint64_t attributes) { return false; }
|
||||
virtual bool SetCreateTimestamp(uint64_t timestamp) { return false; }
|
||||
virtual bool SetAccessTimestamp(uint64_t timestamp) { return false; }
|
||||
virtual bool SetWriteTimestamp(uint64_t timestamp) { return false; }
|
||||
|
||||
bool is_read_only() const;
|
||||
|
||||
Entry* GetChild(const std::string_view name);
|
||||
|
|
Loading…
Reference in New Issue