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 : m_initialized (false), m_fail (false), m_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 : m_initialized (fs.m_initialized), m_fail (fs.m_fail),
55 m_errmsg (fs.m_errmsg), m_mode (fs.m_mode), m_ino (fs.m_ino),
56 m_dev (fs.m_dev), m_nlink (fs.m_nlink), m_uid (fs.m_uid),
57 m_gid (fs.m_gid), m_size (fs.m_size), m_atime (fs.m_atime),
58 m_mtime (fs.m_mtime), m_ctime (fs.m_ctime), m_rdev (fs.m_rdev),
59 m_blksize (fs.m_blksize), m_blocks (fs.m_blocks) { }
91 static sys::time resolution (1.0);
100 bool is_blk ()
const;
101 bool is_chr ()
const;
102 bool is_dir ()
const;
103 bool is_fifo ()
const;
104 bool is_lnk ()
const;
105 bool is_reg ()
const;
106 bool is_sock ()
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 ();
117 static bool have_struct_stat_st_blksize ();
118 static bool have_struct_stat_st_blocks ();
120 ino_t
ino ()
const {
return m_ino; }
121 dev_t
dev ()
const {
return m_dev; }
123 nlink_t
nlink ()
const {
return m_nlink; }
125 uid_t
uid ()
const {
return m_uid; }
126 gid_t
gid ()
const {
return m_gid; }
128 off_t
size ()
const {
return m_size; }
130 sys::time
atime ()
const {
return m_atime; }
131 sys::time
mtime ()
const {
return m_mtime; }
132 sys::time
ctime ()
const {
return m_ctime; }
134 dev_t
rdev ()
const {
return m_rdev; }
137 long blocks ()
const {
return m_blocks; }
139 mode_t
mode ()
const {
return m_mode; }
141 std::string mode_as_string ()
const;
143 bool ok ()
const {
return m_initialized && ! m_fail; }
145 operator bool ()
const {
return ok (); }
149 std::string
error ()
const {
return ok () ?
"" : m_errmsg; }
156 static int is_newer (
const std::string&,
const sys::time&);
219 file_stat (
const std::string&
n =
"",
bool fl =
true);
223 m_follow_links (fs.m_follow_links) { }
231 m_file_name = fs.m_file_name;
232 m_follow_links = fs.m_follow_links;
244 if (! m_initialized || force)
245 update_internal (force);
250 if (
n != m_file_name || ! m_initialized || force)
252 m_initialized =
false;
256 update_internal (force);
263 std::string m_file_name;
269 void update_internal (
bool force =
false);
287 void get_stats (
bool force = false)
289 if (! m_initialized || force)
290 update_internal (force);
295 if (
n != m_fid || ! m_initialized || force)
297 m_initialized =
false;
301 update_internal (force);
310 void update_internal (
bool force =
false);
313 OCTAVE_END_NAMESPACE(sys)
314 OCTAVE_END_NAMESPACE(
octave)
base_file_stat & operator=(const base_file_stat &fs)
base_file_stat(const base_file_stat &fs)
bool is_newer(const sys::time &time) const
std::string error() const
virtual ~base_file_stat()=default
sys::time time_resolution() const
void get_stats(int n, bool force=false)
file_stat(const file_stat &fs)
void get_stats(bool force=false)
void get_stats(const std::string &n, bool force=false)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn