Support for partner file rename/delete

This commit is contained in:
Kyle Reed
2023-05-01 09:25:32 -07:00
parent bf4ed416bd
commit 2cba96ff36
4 changed files with 139 additions and 106 deletions

View File

@@ -197,6 +197,13 @@ std::vector<std::filesystem::path> scan_root_directories(const std::filesystem::
return directory_list;
}
bool file_exists(const std::filesystem::path& file_path) {
FILINFO filinfo;
auto fr = f_stat(reinterpret_cast<const TCHAR*>(file_path.c_str()), &filinfo);
return fr == FR_OK;
}
uint32_t delete_file(const std::filesystem::path& file_path) {
return f_unlink(reinterpret_cast<const TCHAR*>(file_path.c_str()));
}
@@ -251,12 +258,11 @@ std::string filesystem_error::what() const {
}
path path::parent_path() const {
const auto t = filename().native();
const auto index = t.find_last_of(preferred_separator);
if( index == t.npos ) {
return *this;
const auto index = _s.find_last_of(preferred_separator);
if( index == _s.npos ) {
return { }; // NB: Deviation from STL.
} else {
return t.substr(0, index);
return _s.substr(0, index);
}
}
@@ -318,6 +324,12 @@ bool operator>(const path& lhs, const path& rhs) {
return lhs.native() > rhs.native();
}
path operator+(const path& lhs, const path& rhs) {
path result = lhs;
result += rhs;
return result;
}
path operator/(const path& lhs, const path& rhs) {
path result = lhs;
result /= rhs;