]> git.tdb.fi Git - libs/core.git/blob - source/fs/stat.cpp
Add move semantics to Variant
[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::Stat(const Stat &other):
11         exists(other.exists),
12         type(other.type),
13         size(other.type),
14         alloc_size(other.alloc_size),
15         mtime(other.mtime),
16         owner_info(other.owner_info),
17         priv(other.priv ? new Private(*other.priv) : nullptr)
18 { }
19
20 Stat &Stat::operator=(const Stat &other)
21 {
22         if(&other==this)
23                 return *this;
24
25         exists = other.exists;
26         type = other.type;
27         size = other.size;
28         alloc_size = other.alloc_size;
29         mtime = other.mtime;
30         owner_info = other.owner_info;
31         delete priv;
32         priv = (other.priv ? new Private(*other.priv) : nullptr);
33
34         return *this;
35 }
36
37 Stat::~Stat()
38 {
39         delete priv;
40 }
41
42 const string &Stat::get_owner() const
43 {
44         if(priv && owner_info.owner.empty())
45                 priv->fill_owner_info(owner_info);
46         return owner_info.owner;
47 }
48
49 const string &Stat::get_group() const
50 {
51         if(priv && owner_info.group.empty())
52                 priv->fill_owner_info(owner_info);
53         return owner_info.group;
54 }
55
56 } // namespace FS
57 } // namespace Msp