paludis Version 3.0.2
The one true package mangler
fs_stat.hh
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
5 * Copyright (c) 2006 Mark Loeser
6 * Copyright (c) 2008 Fernando J. Pereda
7 *
8 * This file is part of the Paludis package manager. Paludis is free software;
9 * you can redistribute it and/or modify it under the terms of the GNU General
10 * Public License version 2, as published by the Free Software Foundation.
11 *
12 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 * Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef PALUDIS_GUARD_PALUDIS_UTIL_FS_STAT_HH
23#define PALUDIS_GUARD_PALUDIS_UTIL_FS_STAT_HH 1
24
25#include <paludis/util/fs_stat-fwd.hh>
26#include <paludis/util/fs_path-fwd.hh>
27#include <paludis/util/pimp.hh>
29#include <paludis/util/timestamp-fwd.hh>
30#include <utility>
31#include <sys/stat.h>
32
33namespace paludis
34{
35 class PALUDIS_VISIBLE FSStat
36 {
37 private:
38 Pimp<FSStat> _imp;
39
40 public:
41 explicit FSStat(const FSPath &);
42
43 FSStat(const FSStat &);
44
45 FSStat & operator= (const FSStat &);
46
47 ~FSStat();
48
49 bool exists() const PALUDIS_ATTRIBUTE((warn_unused_result));
50 bool is_regular_file() const PALUDIS_ATTRIBUTE((warn_unused_result));
51 bool is_regular_file_or_symlink_to_regular_file() const PALUDIS_ATTRIBUTE((warn_unused_result));
52 bool is_directory() const PALUDIS_ATTRIBUTE((warn_unused_result));
53 bool is_directory_or_symlink_to_directory() const PALUDIS_ATTRIBUTE((warn_unused_result));
54 bool is_symlink() const PALUDIS_ATTRIBUTE((warn_unused_result));
55
56 /**
57 * Return the time the inode for the filesystem entry was last modified
58 *
59 * \exception FSError if there was a problem accessing the filesystem entry
60 */
61 Timestamp ctim() const PALUDIS_ATTRIBUTE((warn_unused_result));
62
63 /**
64 * Return the time the filesystem entry was last modified
65 *
66 * \exception FSError if there was a problem accessing the filesystem entry
67 */
68 Timestamp mtim() const PALUDIS_ATTRIBUTE((warn_unused_result));
69
70 /**
71 * Return the permissions for our item.
72 *
73 * \exception FSError if there was a problem accessing the filesystem entry
74 */
75 mode_t permissions() const PALUDIS_ATTRIBUTE((warn_unused_result));
76
77 /**
78 * Return the size of our file, in bytes.
79 *
80 * \exception FSError if we don't have a size.
81 */
82 off_t file_size() const PALUDIS_ATTRIBUTE((warn_unused_result));
83
84 /**
85 * Fetch our owner.
86 *
87 * \exception FSError If we don't exist or the stat call fails.
88 */
89 uid_t owner() const PALUDIS_ATTRIBUTE((warn_unused_result));
90
91 /**
92 * Fetch our group.
93 *
94 * \exception FSError If we don't exist or the stat call fails.
95 */
96 gid_t group() const PALUDIS_ATTRIBUTE((warn_unused_result));
97
98 /**
99 * Return an unique low-level id for this entry
100 */
101 std::pair<dev_t, ino_t> lowlevel_id() const
102 PALUDIS_ATTRIBUTE((warn_unused_result));
103 };
104
105 extern template class Pimp<FSStat>;
106}
107
108#endif
Definition fs_path.hh:34
uid_t owner() const PALUDIS_ATTRIBUTE((warn_unused_result))
off_t file_size() const PALUDIS_ATTRIBUTE((warn_unused_result))
Timestamp ctim() const PALUDIS_ATTRIBUTE((warn_unused_result))
gid_t group() const PALUDIS_ATTRIBUTE((warn_unused_result))
Timestamp mtim() const PALUDIS_ATTRIBUTE((warn_unused_result))
mode_t permissions() const PALUDIS_ATTRIBUTE((warn_unused_result))
std::pair< dev_t, ino_t > lowlevel_id() const PALUDIS_ATTRIBUTE((warn_unused_result))
Definition pimp.hh:52
Definition timestamp.hh:42
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24