Fix file stat on Windows.
GitOrigin-RevId: 2ca2bb1605af4e25f24d6c06c0aae5ffb8fe09e8
This commit is contained in:
parent
f0e660e2aa
commit
b0be2feebc
@ -1528,6 +1528,8 @@ class CliClient final : public Actor {
|
||||
send_request(make_tl_object<td_api::optimizeStorage>(
|
||||
10000000, -1, -1, 0, std::vector<tl_object_ptr<td_api::FileType>>(), as_chat_ids(chat_ids, ','),
|
||||
as_chat_ids(exclude_chat_ids, ','), to_integer<int32>(chat_ids_limit)));
|
||||
} else if (op == "clean_storage_default") {
|
||||
send_request(make_tl_object<td_api::optimizeStorage>());
|
||||
} else if (op == "clean_storage") {
|
||||
std::vector<tl_object_ptr<td_api::FileType>> types;
|
||||
types.push_back(make_tl_object<td_api::fileTypeThumbnail>());
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
#if TD_PORT_WINDOWS
|
||||
#include "td/utils/misc.h" // for narrow_cast
|
||||
|
||||
#include "td/utils/port/Stat.h"
|
||||
#include "td/utils/port/wstring_convert.h"
|
||||
#endif
|
||||
|
||||
@ -399,6 +401,11 @@ int64 FileFd::get_size() {
|
||||
return stat().size_;
|
||||
}
|
||||
|
||||
static uint64 filetime_to_unix_time_nsec(LONGLONG filetime) {
|
||||
const auto FILETIME_UNIX_TIME_DIFF = 116444736000000000ll;
|
||||
return static_cast<uint64>((filetime - FILETIME_UNIX_TIME_DIFF) * 100);
|
||||
}
|
||||
|
||||
Stat FileFd::stat() {
|
||||
CHECK(!empty());
|
||||
#if TD_PORT_POSIX
|
||||
@ -412,8 +419,8 @@ Stat FileFd::stat() {
|
||||
auto error = OS_ERROR("Stat failed");
|
||||
LOG(FATAL) << error;
|
||||
}
|
||||
res.atime_nsec_ = basic_info.LastAccessTime.QuadPart * 100;
|
||||
res.mtime_nsec_ = basic_info.LastWriteTime.QuadPart * 100;
|
||||
res.atime_nsec_ = filetime_to_unix_time_nsec(basic_info.LastAccessTime.QuadPart);
|
||||
res.mtime_nsec_ = filetime_to_unix_time_nsec(basic_info.LastWriteTime.QuadPart);
|
||||
res.is_dir_ = (basic_info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
res.is_reg_ = true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user