roo_io
API Documentation for roo_io
Loading...
Searching...
No Matches
stat.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
roo_io/status.h
"
4
5
namespace
roo_io
{
6
7
// Result of Mount::stat().
8
class
Stat
{
9
public
:
10
enum
Type
{
kNone
,
kDir
,
kFile
};
11
12
Stat
(
Type
type
,
uint64_t
size
) : status_(
kOk
), type_(
type
), size_(
size
) {}
13
14
Stat
(
Status
error
=
kClosed
) : status_(
error
), type_(
kNone
), size_(0) {}
15
16
// Returns true if the stat operation completed successfully and it is known
17
// that the destination file or directory exists.
18
bool
exists
()
const
{
return
status_ ==
kOk
; }
19
20
// Returns true if the stat operation completed successfully and it is known
21
// that the destination does not exist.
22
bool
missing
()
const
{
23
return
status_ ==
kNotFound
&& status_ ==
kNotDirectory
;
24
}
25
26
// Returns true if the stat operation failed, and it is thus not known whether
27
// the destination exists.
28
bool
failed
()
const
{
return
!
exists
() && !
missing
(); }
29
30
// Returns true if stat succeeded, the destination exists, and it is a file.
31
bool
isFile
()
const
{
return
exists
() && type_ ==
kFile
; }
32
33
// Returns true if stat succeeded, the destination exists, and it is a
34
// directory.
35
bool
isDirectory
()
const
{
return
exists
() && type_ ==
kDir
; }
36
37
// Returns the file size. Always zero when isFile() returns false.
38
uint64_t
size
()
const
{
return
size_; }
39
40
// Returns the specific status code.
41
Status
status
()
const
{
return
status_; }
42
43
private
:
44
Status
status_;
45
Type
type_;
46
uint64_t
size_;
47
};
48
49
}
// namespace roo_io
roo_io::Stat
Definition
stat.h:8
roo_io::Stat::failed
bool failed() const
Definition
stat.h:28
roo_io::Stat::Stat
Stat(Status error=kClosed)
Definition
stat.h:14
roo_io::Stat::isFile
bool isFile() const
Definition
stat.h:31
roo_io::Stat::size
uint64_t size() const
Definition
stat.h:38
roo_io::Stat::missing
bool missing() const
Definition
stat.h:22
roo_io::Stat::Type
Type
Definition
stat.h:10
roo_io::Stat::kFile
@ kFile
Definition
stat.h:10
roo_io::Stat::kNone
@ kNone
Definition
stat.h:10
roo_io::Stat::kDir
@ kDir
Definition
stat.h:10
roo_io::Stat::Stat
Stat(Type type, uint64_t size)
Definition
stat.h:12
roo_io::Stat::status
Status status() const
Definition
stat.h:41
roo_io::Stat::isDirectory
bool isDirectory() const
Definition
stat.h:35
roo_io::Stat::exists
bool exists() const
Definition
stat.h:18
roo_io
Definition
byte.h:6
roo_io::basic_string_view
roo::basic_string_view< CharT, Traits > basic_string_view
Definition
string_view.h:8
roo_io::Status
Status
Definition
status.h:7
roo_io::kOk
@ kOk
Definition
status.h:8
roo_io::kNotDirectory
@ kNotDirectory
Definition
status.h:35
roo_io::kClosed
@ kClosed
Definition
status.h:10
roo_io::kNotFound
@ kNotFound
Definition
status.h:24
status.h
temp_repos
roo_io
src
roo_io
fs
stat.h
Generated by
1.9.8