Mercurial > octave
annotate liboctave/system/file-stat.h @ 22868:87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
* make_int.cc, Canvas.h, GenericEventNotify.h, TextEdit.h, gl-select.h, QTerminal.h, files-dock-widget.h, history-dock-widget.h, octave-cmd.h, octave-dock-widget.h, octave-interpreter.h, thread-manager.h, welcome-wizard.h, workspace-model.h, workspace-view.h, base-text-renderer.h, comment-list.h, debug.h, dynamic-ld.cc, dynamic-ld.h, ft-text-renderer.cc, gl-render.h, gl2ps-print.cc, graphics.in.h, hook-fcn.h, input.h, load-path.h, mxarray.in.h, oct-errno.h, oct-fstrm.h, oct-handle.h, oct-iostrm.h, oct-lvalue.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.h, pr-output.cc, procstream.h, sighandlers.cc, symtab.h, text-renderer.h, txt-eng.h, variables.cc, workspace-element.h, __init_fltk__.cc, __init_gnuplot__.cc, ov-base-diag.h, ov-base-int.h, ov-base-scalar.h, ov-base-sparse.h, ov-base.h, ov-bool-mat.h, ov-bool-sparse.h, ov-bool.h, ov-builtin.h, ov-cell.h, ov-ch-mat.h, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.h, ov-cx-diag.h, ov-cx-mat.h, ov-cx-sparse.h, ov-fcn-handle.h, ov-fcn-inline.h, ov-fcn.h, ov-float.h, ov-flt-complex.h, ov-flt-cx-diag.h, ov-flt-cx-mat.h, ov-flt-re-diag.h, ov-flt-re-mat.h, ov-intx.h, ov-lazy-idx.h, ov-re-diag.h, ov-re-mat.h, ov-re-sparse.h, ov-scalar.h, ov-str-mat.h, ov-struct.h, ov-typeinfo.h, ov-usr-fcn.h, ovl.h, octave.h, lex.h, parse.h, pt-binop.h, pt-bp.h, pt-cell.h, pt-check.h, pt-classdef.h, pt-cmd.h, pt-const.h, pt-decl.h, pt-eval.h, pt-exp.h, pt-fcn-handle.h, pt-funcall.h, pt-id.h, pt-jump.h, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.h, pt-pr-code.h, pt-unop.h, pt-walk.h, pt.h, DiagArray2.h, MArray.h, MDiagArray2.h, MSparse.h, idx-vector.h, quit.h, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK.h, DASRT.h, DASSL.h, EIG.h, LSODE.h, ODE.h, ODEFunc.h, ODES.h, ODESFunc.h, Quad.h, aepbalance.h, base-dae.h, base-de.h, base-min.h, fEIG.h, gepbalance.h, gsvd.h, hess.h, lu.h, oct-rand.h, oct-spparms.h, qr.h, qrp.h, schur.h, sparse-lu.h, svd.h, child-list.h, file-stat.h, oct-passwd.h, oct-time.h, oct-uname.h, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, glob-match.h, lo-array-errwarn.h, lo-regexp.h, oct-mutex.h, pathsearch.h, str-vec.h, url-transfer.h:
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 06 Dec 2016 10:59:29 -0500 |
parents | 3a2b891d0b33 |
children | ef4d915df748 |
rev | line source |
---|---|
2926 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
21935
diff
changeset
|
3 Copyright (C) 1996-2016 John W. Eaton |
2926 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
10 (at your option) any later version. |
2926 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
15 GNU General Public License for more details. |
2926 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2926 | 20 |
21 */ | |
22 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 #if ! defined (octave_file_stat_h) |
2926 | 24 #define octave_file_stat_h 1 |
25 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
27 |
2926 | 28 #include <string> |
29 | |
3260 | 30 #include "oct-time.h" |
31 | |
2926 | 32 #include <sys/types.h> |
33 | |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
34 namespace octave |
2926 | 35 { |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
36 namespace sys |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
37 { |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
38 class |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
39 OCTAVE_API |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
40 base_file_stat |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
41 { |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
42 public: |
2926 | 43 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
44 base_file_stat (void) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
45 : initialized (false), fail (false), errmsg (), m_mode (), |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
46 m_ino (), m_dev (), m_nlink (), m_uid (), m_gid (), |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
47 m_size (), m_atime (), m_mtime (), m_ctime (), m_rdev (), |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
48 m_blksize (), m_blocks () { } |
8549 | 49 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
50 base_file_stat (const base_file_stat& fs) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
51 : initialized (fs.initialized), fail (fs.fail), errmsg (fs.errmsg), |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
52 m_mode (fs.m_mode), m_ino (fs.m_ino), m_dev (fs.m_dev), |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
53 m_nlink (fs.m_nlink), m_uid (fs.m_uid), m_gid (fs.m_gid), |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
54 m_size (fs.m_size), m_atime (fs.m_atime), m_mtime (fs.m_mtime), |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
55 m_ctime (fs.m_ctime), m_rdev (fs.m_rdev), |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
56 m_blksize (fs.m_blksize), m_blocks (fs.m_blocks) { } |
8549 | 57 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
58 base_file_stat& operator = (const base_file_stat& fs) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
59 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
60 if (this != &fs) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
61 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
62 initialized = fs.initialized; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
63 fail = fs.fail; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
64 errmsg = fs.errmsg; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
65 m_mode = fs.m_mode; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
66 m_ino = fs.m_ino; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
67 m_dev = fs.m_dev; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
68 m_nlink = fs.m_nlink; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
69 m_uid = fs.m_uid; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
70 m_gid = fs.m_gid; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
71 m_size = fs.m_size; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
72 m_atime = fs.m_atime; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
73 m_mtime = fs.m_mtime; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
74 m_ctime = fs.m_ctime; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
75 m_rdev = fs.m_rdev; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
76 m_blksize = fs.m_blksize; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
77 m_blocks = fs.m_blocks; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
78 } |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
79 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
80 return *this; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
81 } |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
82 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
83 // The minimum difference in file time stamp values. |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
84 // FIXME: This value should come from the filesystem itself. |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
85 // How can we get that info? |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
86 octave::sys::time time_resolution (void) const |
2926 | 87 { |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
88 static octave::sys::time resolution (1.0); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
89 return resolution; |
2926 | 90 } |
91 | |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
92 // File status and info. The is_XXX functions will return false for |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
93 // file_stat objects that are not properly initialized. The others |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
94 // should all return 0 (or the equivalent, for the given object) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
95 // which is likely not meaningful. |
2926 | 96 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
97 bool is_blk (void) const; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
98 bool is_chr (void) const; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
99 bool is_dir (void) const; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
100 bool is_fifo (void) const; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
101 bool is_lnk (void) const; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
102 bool is_reg (void) const; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
103 bool is_sock (void) const; |
2926 | 104 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
105 static bool is_blk (mode_t mode); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
106 static bool is_chr (mode_t mode); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
107 static bool is_dir (mode_t mode); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
108 static bool is_fifo (mode_t mode); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
109 static bool is_lnk (mode_t mode); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
110 static bool is_reg (mode_t mode); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
111 static bool is_sock (mode_t mode); |
2926 | 112 |
21935 | 113 static bool have_struct_stat_st_rdev (void); |
114 static bool have_struct_stat_st_blksize (void); | |
115 static bool have_struct_stat_st_blocks (void); | |
116 | |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
117 ino_t ino (void) const { return m_ino; } |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
118 dev_t dev (void) const { return m_dev; } |
5476 | 119 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
120 nlink_t nlink (void) const { return m_nlink; } |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
121 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
122 uid_t uid (void) const { return m_uid; } |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
123 gid_t gid (void) const { return m_gid; } |
2926 | 124 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
125 off_t size (void) const { return m_size; } |
2926 | 126 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
127 octave::sys::time atime (void) const { return m_atime; } |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
128 octave::sys::time mtime (void) const { return m_mtime; } |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
129 octave::sys::time ctime (void) const { return m_ctime; } |
2926 | 130 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
131 dev_t rdev (void) const { return m_rdev; } |
2926 | 132 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
133 long blksize (void) const { return m_blksize; } |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
134 long blocks (void) const { return m_blocks; } |
2926 | 135 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
136 mode_t mode (void) const { return m_mode; } |
2926 | 137 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
138 std::string mode_as_string (void) const; |
5476 | 139 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
140 bool ok (void) const { return initialized && ! fail; } |
2926 | 141 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
142 operator bool () const { return ok (); } |
2926 | 143 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
144 bool exists (void) const { return ok (); } |
2926 | 145 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
146 std::string error (void) const { return ok () ? "" : errmsg; } |
2926 | 147 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
148 // Has the file referenced by this object been modified since TIME? |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
149 bool is_newer (const octave::sys::time& time) const { return m_mtime > time; } |
2926 | 150 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
151 // It's nice to be able to hide the file_stat object if we don't |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
152 // really care about it. |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
153 static int is_newer (const std::string&, const octave::sys::time&); |
2926 | 154 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
155 protected: |
11506
964b7fd379f1
more constructor/destructor fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
156 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
157 virtual ~base_file_stat (void) = default; |
2926 | 158 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
159 // TRUE means we have already called stat. |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
160 bool initialized; |
2926 | 161 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
162 // TRUE means the stat for this file failed. |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
163 bool fail; |
2926 | 164 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
165 // If a failure occurs, this contains the system error text. |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
166 std::string errmsg; |
2926 | 167 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
168 // file type and permissions |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
169 mode_t m_mode; |
2926 | 170 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
171 // serial number |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
172 ino_t m_ino; |
2926 | 173 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
174 // device number |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
175 dev_t m_dev; |
2926 | 176 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
177 // number of links |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
178 nlink_t m_nlink; |
2926 | 179 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
180 // user ID of owner |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
181 uid_t m_uid; |
2926 | 182 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
183 // group ID of owner |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
184 gid_t m_gid; |
2926 | 185 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
186 // size in bytes, for regular files |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
187 off_t m_size; |
2926 | 188 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
189 // time of last access |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
190 octave::sys::time m_atime; |
2926 | 191 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
192 // time of last modification |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
193 octave::sys::time m_mtime; |
8549 | 194 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
195 // time of last file status change |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
196 octave::sys::time m_ctime; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
197 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
198 // device number for special files |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
199 dev_t m_rdev; |
8549 | 200 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
201 // best I/O block size |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
202 long m_blksize; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
203 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
204 // number of 512-byte blocks allocated |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
205 long m_blocks; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
206 }; |
8549 | 207 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
208 class |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
209 OCTAVE_API |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
210 file_stat : public base_file_stat |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
211 { |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
212 public: |
8549 | 213 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
214 file_stat (const std::string& n = "", bool fl = true) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
215 : base_file_stat (), file_name (n), follow_links (fl) |
8549 | 216 { |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
217 if (! file_name.empty ()) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
218 update_internal (); |
8549 | 219 } |
220 | |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
221 file_stat (const file_stat& fs) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
222 : base_file_stat (fs), file_name (fs.file_name), |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
223 follow_links (fs.follow_links) { } |
8549 | 224 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
225 file_stat& operator = (const file_stat& fs) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
226 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
227 if (this != &fs) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
228 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
229 base_file_stat::operator = (fs); |
8549 | 230 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
231 file_name = fs.file_name; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
232 follow_links = fs.follow_links; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
233 } |
8549 | 234 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
235 return *this; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
236 } |
8549 | 237 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
238 ~file_stat (void) = default; |
8549 | 239 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
240 void get_stats (bool force = false) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
241 { |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
242 if (! initialized || force) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
243 update_internal (force); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
244 } |
8549 | 245 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
246 void get_stats (const std::string& n, bool force = false) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
247 { |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
248 if (n != file_name || ! initialized || force) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
249 { |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
250 initialized = false; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
251 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
252 file_name = n; |
2926 | 253 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
254 update_internal (force); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
255 } |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
256 } |
2926 | 257 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
258 private: |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
259 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
260 // Name of the file. |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
261 std::string file_name; |
8549 | 262 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
263 // TRUE means follow symbolic links to the ultimate file (stat). |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
264 // FALSE means get information about the link itself (lstat). |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
265 bool follow_links; |
8549 | 266 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
267 void update_internal (bool force = false); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
268 }; |
8549 | 269 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
270 class |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
271 OCTAVE_API |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
272 file_fstat : public base_file_stat |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
273 { |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
274 public: |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
275 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
276 file_fstat (int n) : base_file_stat (), fid (n) |
8549 | 277 { |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
278 update_internal (); |
8549 | 279 } |
280 | |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
281 file_fstat (const file_fstat& fs) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
282 : base_file_stat (fs), fid (fs.fid) { } |
8549 | 283 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
284 file_fstat& operator = (const file_fstat& fs) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
285 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
286 if (this != &fs) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
287 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
288 base_file_stat::operator = (fs); |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
289 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
290 fid = fs.fid; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
291 } |
8549 | 292 |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
293 return *this; |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
294 } |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
295 |
22868
87e3163f6c87
use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents:
22755
diff
changeset
|
296 ~file_fstat (void) = default; |
8549 | 297 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
298 void get_stats (bool force = false) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
299 { |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
300 if (! initialized || force) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
301 update_internal (force); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
302 } |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
303 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
304 void get_stats (int n, bool force = false) |
8549 | 305 { |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
306 if (n != fid || ! initialized || force) |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
307 { |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
308 initialized = false; |
8549 | 309 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
310 fid = n; |
8549 | 311 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
312 update_internal (force); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
313 } |
8549 | 314 } |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
315 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
316 private: |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
317 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
318 // Open file descriptor. |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
319 int fid; |
8549 | 320 |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
321 void update_internal (bool force = false); |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
322 }; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
323 } |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
324 } |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
325 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
326 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) |
8549 | 327 |
21752
949cb46e6bdb
use consistent style for deprecated function/class messages
John W. Eaton <jwe@octave.org>
parents:
21736
diff
changeset
|
328 OCTAVE_DEPRECATED ("use 'octave::sys::base_file_stat' instead") |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
329 typedef octave::sys::base_file_stat base_file_stat; |
8549 | 330 |
21752
949cb46e6bdb
use consistent style for deprecated function/class messages
John W. Eaton <jwe@octave.org>
parents:
21736
diff
changeset
|
331 OCTAVE_DEPRECATED ("use 'octave::sys::file_stat' instead") |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
332 typedef octave::sys::file_stat file_stat; |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
333 |
21752
949cb46e6bdb
use consistent style for deprecated function/class messages
John W. Eaton <jwe@octave.org>
parents:
21736
diff
changeset
|
334 OCTAVE_DEPRECATED ("use 'octave::sys::file_fstat' instead") |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
335 typedef octave::sys::file_fstat file_fstat; |
2926 | 336 |
337 #endif | |
21736
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
338 |
0504351a45e6
use namespace for file_stat classes
John W. Eaton <jwe@octave.org>
parents:
21730
diff
changeset
|
339 #endif |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
340 |