aboutsummaryrefslogtreecommitdiffhomepage
path: root/tdutils/td/utils/port/Stat.h
blob: 305f71d454406fb8ce7f1cfaab452d543ce5f5f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2025
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once

#include "td/utils/port/config.h"

#include "td/utils/common.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"

namespace td {

struct Stat {
  bool is_dir_;
  bool is_reg_;
  bool is_symbolic_link_;
  int64 size_;
  int64 real_size_;
  uint64 atime_nsec_;
  uint64 mtime_nsec_;
};

Result<Stat> stat(CSlice path) TD_WARN_UNUSED_RESULT;

struct CpuStat {
  uint64 total_ticks_{0};
  uint64 process_user_ticks_{0};
  uint64 process_system_ticks_{0};
};

Result<CpuStat> cpu_stat() TD_WARN_UNUSED_RESULT;

struct MemStat {
  uint64 resident_size_ = 0;
  uint64 resident_size_peak_ = 0;
  uint64 virtual_size_ = 0;
  uint64 virtual_size_peak_ = 0;
};

Result<MemStat> mem_stat() TD_WARN_UNUSED_RESULT;

#if TD_PORT_POSIX

namespace detail {
Result<Stat> fstat(int native_fd);
}  // namespace detail

Status update_atime(CSlice path) TD_WARN_UNUSED_RESULT;

#endif

}  // namespace td