26 #if ! defined (octave_file_stat_h)
27 #define octave_file_stat_h 1
29 #include "octave-config.h"
35 #include <sys/types.h>
48 : initialized (false), fail (false), errmsg (), m_mode (),
49 m_ino (), m_dev (), m_nlink (), m_uid (), m_gid (),
50 m_size (), m_atime (), m_mtime (), m_ctime (), m_rdev (),
51 m_blksize (), m_blocks () { }
54 : initialized (fs.initialized), fail (fs.fail), errmsg (fs.errmsg),
55 m_mode (fs.m_mode), m_ino (fs.m_ino), m_dev (fs.m_dev),
56 m_nlink (fs.m_nlink), m_uid (fs.m_uid), m_gid (fs.m_gid),
57 m_size (fs.m_size), m_atime (fs.m_atime), m_mtime (fs.m_mtime),
58 m_ctime (fs.m_ctime), m_rdev (fs.m_rdev),
59 m_blksize (fs.m_blksize), m_blocks (fs.m_blocks) { }
100 bool is_blk (
void)
const;
101 bool is_chr (
void)
const;
102 bool is_dir (
void)
const;
103 bool is_fifo (
void)
const;
104 bool is_lnk (
void)
const;
105 bool is_reg (
void)
const;
106 bool is_sock (
void)
const;
108 static bool is_blk (mode_t mode);
109 static bool is_chr (mode_t mode);
110 static bool is_dir (mode_t mode);
111 static bool is_fifo (mode_t mode);
112 static bool is_lnk (mode_t mode);
113 static bool is_reg (mode_t mode);
114 static bool is_sock (mode_t mode);
116 static bool have_struct_stat_st_rdev (
void);
117 static bool have_struct_stat_st_blksize (
void);
118 static bool have_struct_stat_st_blocks (
void);
120 ino_t
ino (
void)
const {
return m_ino; }
121 dev_t
dev (
void)
const {
return m_dev; }
123 nlink_t
nlink (
void)
const {
return m_nlink; }
125 uid_t
uid (
void)
const {
return m_uid; }
126 gid_t
gid (
void)
const {
return m_gid; }
128 off_t
size (
void)
const {
return m_size; }
134 dev_t
rdev (
void)
const {
return m_rdev; }
136 long blksize (
void)
const {
return m_blksize; }
137 long blocks (
void)
const {
return m_blocks; }
139 mode_t
mode (
void)
const {
return m_mode; }
141 std::string mode_as_string (
void)
const;
143 bool ok (
void)
const {
return initialized && ! fail; }
145 operator bool ()
const {
return ok (); }
147 bool exists (
void)
const {
return ok (); }
149 std::string
error (
void)
const {
return ok () ?
"" : errmsg; }
156 static int is_newer (
const std::string&,
const sys::time&);
219 file_stat (
const std::string&
n =
"",
bool fl =
true);
223 follow_links (fs.follow_links) { }
244 if (! initialized || force)
245 update_internal (force);
250 if (
n != file_name || ! initialized || force)
256 update_internal (force);
269 void update_internal (
bool force =
false);
302 if (! initialized || force)
303 update_internal (force);
308 if (
n != fid || ! initialized || force)
314 update_internal (force);
323 void update_internal (
bool force =
false);
sys::time mtime(void) const
nlink_t nlink(void) const
base_file_stat(const base_file_stat &fs)
std::string error(void) const
sys::time time_resolution(void) const
sys::time atime(void) const
base_file_stat & operator=(const base_file_stat &fs)
bool is_newer(const sys::time &time) const
sys::time ctime(void) const
virtual ~base_file_stat(void)=default
void get_stats(int n, bool force=false)
void get_stats(bool force=false)
file_fstat(const file_fstat &fs)
~file_fstat(void)=default
void get_stats(bool force=false)
void get_stats(const std::string &n, bool force=false)
file_stat(const file_stat &fs)