MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / SetFileTimestamp

Function SetFileTimestamp

src/common/local_storage.cpp:1311–1332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1309}
1310
1311bool SetFileTimestamp(uint32_t accountId, uint32_t appId, const std::string& filename, uint64_t unixSeconds) {
1312 if (unixSeconds == 0) return false;
1313 std::lock_guard<std::shared_mutex> lock(g_mutex);
1314
1315 std::string appRoot = GetAppPathInternal(accountId, appId);
1316 std::string fullPath = ValidateFilename(appRoot, filename);
1317 if (fullPath.empty()) {
1318 LOG("SetFileTimestamp BLOCKED: path traversal in filename '%s'", filename.c_str());
1319 return false;
1320 }
1321
1322 auto fileTime = UnixSecondsToFileTime(unixSeconds);
1323
1324 std::error_code ec;
1325 std::filesystem::last_write_time(FileUtil::Utf8ToPath(fullPath), fileTime, ec);
1326 if (ec) {
1327 LOG("SetFileTimestamp: failed for %s: %s", filename.c_str(), ec.message().c_str());
1328 return false;
1329 }
1330 LOG("SetFileTimestamp: %s -> %llu", filename.c_str(), unixSeconds);
1331 return true;
1332}
1333
1334} // namespace LocalStorage

Callers 1

RepairCloudManifestFunction · 0.85

Calls 4

ValidateFilenameFunction · 0.85
UnixSecondsToFileTimeFunction · 0.85
GetAppPathInternalFunction · 0.70
Utf8ToPathFunction · 0.70

Tested by

no test coverage detected