]> git.tdb.fi Git - libs/core.git/blob - source/fs/stat.cpp
Move most platform-specific code into overlay directories
[libs/core.git] / source / fs / stat.cpp
1 #include "path.h"
2 #include "stat.h"
3 #include "stat_private.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace FS {
9
10 Stat::Private::Private():
11         owner_id(0),
12         group_id(0)
13 { }
14
15
16 Stat::Stat():
17         exists(false),
18         type(UNKNOWN),
19         size(0),
20         alloc_size(0),
21         priv(0)
22 { }
23
24 Stat::Stat(const Stat &other):
25         exists(other.exists),
26         type(other.type),
27         size(other.type),
28         alloc_size(other.alloc_size),
29         mtime(other.mtime),
30         owner_info(other.owner_info),
31         priv(other.priv ? new Private(*other.priv) : 0)
32 { }
33
34 Stat &Stat::operator=(const Stat &other)
35 {
36         exists = other.exists;
37         type = other.type;
38         size = other.size;
39         alloc_size = other.alloc_size;
40         mtime = other.mtime;
41         owner_info = other.owner_info;
42         delete priv;
43         priv = (other.priv ? new Private(*other.priv) : 0);
44
45         return *this;
46 }
47
48 Stat::~Stat()
49 {
50         delete priv;
51 }
52
53 const std::string &Stat::get_owner() const
54 {
55         if(priv && owner_info.owner.empty())
56                 priv->fill_owner_info(owner_info);
57         return owner_info.owner;
58 }
59
60 const std::string &Stat::get_group() const
61 {
62         if(priv && owner_info.group.empty())
63                 priv->fill_owner_info(owner_info);
64         return owner_info.group;
65 }
66
67 } // namespace FS
68 } // namespace Msp