Mercurial > octave
annotate liboctave/system/dir-ops.cc @ 21202:f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
* Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc,
Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc,
Array-voidp.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc,
CNDArray.cc, CRowVector.cc, CSparse.cc, CSparse.h, DiagArray2.cc, MArray-C.cc,
MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc,
MDiagArray2.cc, MSparse-C.cc, MSparse-d.cc, MSparse.h, MatrixType.cc,
PermMatrix.cc, Range.cc, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc,
boolMatrix.cc, boolNDArray.cc, boolSparse.cc, chMatrix.cc, chNDArray.cc,
dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc,
dSparse.cc, dSparse.h, dim-vector.cc, fCColVector.cc, fCDiagMatrix.cc,
fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc,
fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, int16NDArray.cc,
int32NDArray.cc, int64NDArray.cc, int8NDArray.cc, intNDArray.cc,
uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc,
blaswrap.c, cquit.c, f77-extern.cc, f77-fcn.c, f77-fcn.h, lo-error.c, quit.cc,
quit.h, CmplxAEPBAL.cc, CmplxCHOL.cc, CmplxGEPBAL.cc, CmplxHESS.cc, CmplxLU.cc,
CmplxQR.cc, CmplxQRP.cc, CmplxSCHUR.cc, CmplxSVD.cc, CollocWt.cc, DASPK.cc,
DASRT.cc, DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, base-lu.cc, base-qr.cc,
dbleAEPBAL.cc, dbleCHOL.cc, dbleGEPBAL.cc, dbleHESS.cc, dbleLU.cc, dbleQR.cc,
dbleQRP.cc, dbleSCHUR.cc, dbleSVD.cc, eigs-base.cc, fCmplxAEPBAL.cc,
fCmplxCHOL.cc, fCmplxGEPBAL.cc, fCmplxHESS.cc, fCmplxLU.cc, fCmplxQR.cc,
fCmplxQRP.cc, fCmplxSCHUR.cc, fCmplxSVD.cc, fEIG.cc, floatAEPBAL.cc,
floatCHOL.cc, floatGEPBAL.cc, floatHESS.cc, floatLU.cc, floatQR.cc,
floatQRP.cc, floatSCHUR.cc, floatSVD.cc, lo-mappers.cc, lo-specfun.cc,
oct-convn.cc, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-rand.cc,
oct-spparms.cc, randgamma.c, randmtzig.c, randpoisson.c, sparse-chol.cc,
sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, mx-defs.h, dir-ops.cc,
file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc,
oct-group.cc, oct-openmp.h, oct-passwd.cc, oct-syscalls.cc, oct-time.cc,
oct-uname.cc, pathlen.h, sysdir.h, syswait.h, cmd-edit.cc, cmd-hist.cc,
data-conv.cc, f2c-main.c, glob-match.cc, lo-array-errwarn.cc,
lo-array-gripes.cc, lo-cutils.c, lo-cutils.h, lo-ieee.cc, lo-math.h,
lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc, oct-inttypes.cc,
oct-inttypes.h, oct-locbuf.cc, oct-mutex.cc, oct-refcount.h, oct-rl-edit.c,
oct-rl-hist.c, oct-shlib.cc, oct-sort.cc, pathsearch.cc, singleton-cleanup.cc,
sparse-sort.cc, sparse-util.cc, statdefs.h, str-vec.cc, unwind-prot.cc,
url-transfer.cc, display-available.h, main-cli.cc, main-gui.cc, main.in.cc,
mkoctfile.in.cc, octave-config.in.cc, shared-fcns.h:
indent #ifdef blocks in liboctave and src directories.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 06 Feb 2016 06:40:13 -0800 |
parents | 2469d78a1d8b |
children | 40de9f8f23a6 |
rev | line source |
---|---|
1782 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
3 Copyright (C) 1996-2015 John W. Eaton |
1782 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1782 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
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/>. | |
1782 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
21202
f7121e111991
maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents:
20713
diff
changeset
|
24 # include <config.h> |
1782 | 25 #endif |
26 | |
27 #include <cerrno> | |
2926 | 28 #include <cstdlib> |
1782 | 29 #include <cstring> |
30 | |
8326
545b9f62adcf
dir-ops.cc (dir_entry::read): use std::list<std::string> to cache names before converting to string_vector
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
31 #include <list> |
545b9f62adcf
dir-ops.cc (dir_entry::read): use std::list<std::string> to cache names before converting to string_vector
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
32 #include <string> |
545b9f62adcf
dir-ops.cc (dir_entry::read): use std::list<std::string> to cache names before converting to string_vector
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
33 |
1782 | 34 #include "sysdir.h" |
35 | |
36 #include "dir-ops.h" | |
5871 | 37 #include "file-ops.h" |
2926 | 38 #include "lo-error.h" |
39 #include "lo-sysdep.h" | |
1782 | 40 #include "str-vec.h" |
41 | |
42 bool | |
3504 | 43 dir_entry::open (const std::string& n) |
1782 | 44 { |
45 fail = true; | |
46 | |
47 if (! n.empty ()) | |
48 name = n; | |
49 | |
50 if (! name.empty ()) | |
51 { | |
52 close (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
53 |
5871 | 54 std::string fullname = file_ops::tilde_expand (name); |
1782 | 55 |
10411 | 56 dir = static_cast<void *> (gnulib::opendir (fullname.c_str ())); |
1782 | 57 |
58 if (dir) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
59 fail = false; |
1782 | 60 else |
10411 | 61 errmsg = gnulib::strerror (errno); |
1782 | 62 } |
63 else | |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
64 errmsg = "dir_entry::open: empty filename"; |
1782 | 65 |
66 return ! fail; | |
67 } | |
68 | |
69 string_vector | |
70 dir_entry::read (void) | |
71 { | |
8326
545b9f62adcf
dir-ops.cc (dir_entry::read): use std::list<std::string> to cache names before converting to string_vector
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
72 string_vector retval; |
1782 | 73 |
74 if (ok ()) | |
75 { | |
8326
545b9f62adcf
dir-ops.cc (dir_entry::read): use std::list<std::string> to cache names before converting to string_vector
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
76 std::list<std::string> dirlist; |
1782 | 77 |
78 struct dirent *dir_ent; | |
79 | |
14155 | 80 while ((dir_ent = gnulib::readdir (static_cast<DIR *> (dir)))) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
81 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
82 if (dir_ent) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
83 dirlist.push_back (dir_ent->d_name); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
84 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
85 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
86 } |
6145 | 87 |
8326
545b9f62adcf
dir-ops.cc (dir_entry::read): use std::list<std::string> to cache names before converting to string_vector
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
88 retval = string_vector (dirlist); |
1782 | 89 } |
90 | |
8326
545b9f62adcf
dir-ops.cc (dir_entry::read): use std::list<std::string> to cache names before converting to string_vector
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
91 return retval; |
1782 | 92 } |
93 | |
94 void | |
95 dir_entry::close (void) | |
96 { | |
97 if (dir) | |
10411 | 98 gnulib::closedir (static_cast<DIR *> (dir)); |
1782 | 99 |
100 dir = 0; | |
101 } |