libsshpp v0.1.7
Modern C++17 wrapper for libssh
Loading...
Searching...
No Matches
attributes.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later
2#pragma once
3
4#include <sshpp/export.hpp>
5
6#include <chrono>
7#include <cstdint>
8#include <filesystem>
9#include <optional>
10#include <string>
11#include <utility>
12
13namespace sshpp::sftp {
14
17
19struct SSHPP_API Attributes {
20 std::string name;
21 std::string long_name;
22 FileType type = FileType::unknown;
23 std::uint64_t size = 0;
24 std::uint32_t uid = 0, gid = 0;
25 std::optional<std::string> owner, group;
26 std::uint32_t permissions = 0;
27 std::uint32_t flags = 0;
28
29 std::optional<std::chrono::system_clock::time_point> atime, mtime, createtime;
30
31 bool is_regular() const noexcept { return type == FileType::regular; }
32 bool is_directory() const noexcept { return type == FileType::directory; }
33 bool is_symlink() const noexcept { return type == FileType::symlink; }
34 std::filesystem::perms std_perms() const noexcept {
35 return static_cast<std::filesystem::perms>(permissions & 07777u);
36 }
37};
38
40struct SSHPP_API AttributeUpdate {
41 std::optional<std::uint64_t> size;
42 std::optional<std::uint32_t> permissions;
43 std::optional<std::pair<std::uint32_t, std::uint32_t>> uid_gid;
44 std::optional<std::chrono::system_clock::time_point> atime, mtime;
45};
46
47} // namespace sshpp::sftp
Definition algorithms.ipp:10
FileType
Definition attributes.hpp:15
Partial attributes for setstat: only engaged fields are transmitted.
Definition attributes.hpp:40
std::optional< std::uint32_t > permissions
Definition attributes.hpp:42
std::optional< std::chrono::system_clock::time_point > atime
Definition attributes.hpp:44
std::optional< std::uint64_t > size
Definition attributes.hpp:41
std::optional< std::pair< std::uint32_t, std::uint32_t > > uid_gid
Definition attributes.hpp:43
Value-type copy of libssh's sftp_attributes. See docs/design/06 ยง6.1.
Definition attributes.hpp:19
bool is_regular() const noexcept
Definition attributes.hpp:31
std::string name
Definition attributes.hpp:20
std::optional< std::chrono::system_clock::time_point > atime
Definition attributes.hpp:29
std::filesystem::perms std_perms() const noexcept
Definition attributes.hpp:34
bool is_directory() const noexcept
Definition attributes.hpp:32
std::string long_name
Definition attributes.hpp:21
bool is_symlink() const noexcept
Definition attributes.hpp:33
std::optional< std::string > group
Definition attributes.hpp:25