GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
file-ops.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2023 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_file_ops_h)
27 #define octave_file_ops_h 1
28 
29 #include "octave-config.h"
30 
31 #include <string>
32 
33 #include <sys/types.h>
34 
35 #include "str-vec.h"
36 
38 
40 
41 OCTAVE_BEGIN_NAMESPACE(file_ops)
42 
43 typedef std::string (*tilde_expansion_hook) (const std::string&);
44 
45 // If non-null, this contains the address of a function that the
46 // application wants called before trying the standard tilde
47 // expansions. The function is called with the text sans tilde, and
48 // returns a malloc()'ed string which is the expansion, or a NULL
49 // pointer if the expansion fails.
50 
52 
53 // If non-null, this contains the address of a function to call if the
54 // standard meaning for expanding a tilde fails. The function is
55 // called with the text (sans tilde, as in "foo"), and returns a
56 // malloc()'ed string which is the expansion, or a NULL pointer if
57 // there is no expansion.
58 
60 
61 // When non-null, this is a NULL terminated array of strings which are
62 // duplicates for a tilde prefix. Bash uses this to expand '=~' and
63 // ':~'.
64 
66 
67 // When non-null, this is a NULL terminated array of strings which
68 // match the end of a username, instead of just "/". Bash sets this
69 // to ':' and '=~'.
70 
72 
73 // Find the start of a tilde expansion in S, and return the index
74 // of the tilde which starts the expansion. Place the length of the
75 // text which identified this tilde starter in LEN, excluding the
76 // tilde itself.
77 
78 extern OCTAVE_API char dev_sep_char (void);
79 
80 extern OCTAVE_API bool is_dev_sep (char c);
81 
82 extern OCTAVE_API char dir_sep_char (void);
83 
84 extern OCTAVE_API std::string dir_sep_str (void);
85 
86 extern OCTAVE_API std::string dir_sep_chars (void);
87 
88 extern OCTAVE_API bool is_dir_sep (char c);
89 
90 // If NAME has a leading ~ or ~user, Unix-style, expand it to the
91 // user's home directory. If no ~, or no <pwd.h>, just return NAME.
92 
93 extern OCTAVE_API std::string tilde_expand (const std::string&);
94 
95 // A vector version of the above.
96 
98 
99 extern OCTAVE_API std::string concat (const std::string&, const std::string&);
100 
101 // Return the directory part of a filename or an empty string if
102 // there is no directory component. Does not check to see
103 // whether the file exists or is a directory.
104 
105 extern OCTAVE_API std::string dirname (const std::string& path);
106 
107 // Return the tail member of a filename.
108 
109 extern OCTAVE_API std::string tail (const std::string& path);
110 
111 // Convert path from UNIX type separators to whatever is the
112 // system separators.
113 
114 extern OCTAVE_API std::string
115 native_separator_path (const std::string& path);
116 
117 OCTAVE_END_NAMESPACE(file_ops)
118 
119 extern OCTAVE_API int
120 mkdir (const std::string&, mode_t);
121 
122 extern OCTAVE_API int
123 mkdir (const std::string&, mode_t, std::string&);
124 
125 extern OCTAVE_API int
126 recursive_mkdir (const std::string& name, mode_t mode);
127 
128 extern OCTAVE_API int
129 recursive_mkdir (const std::string& name, mode_t mode, std::string& msg);
130 
131 extern OCTAVE_API int
132 mkfifo (const std::string&, mode_t);
133 
134 extern OCTAVE_API int
135 mkfifo (const std::string&, mode_t, std::string&);
136 
137 extern OCTAVE_API int
138 link (const std::string&, const std::string&);
139 
140 extern OCTAVE_API int
141 link (const std::string&, const std::string&, std::string&);
142 
143 extern OCTAVE_API int
144 symlink (const std::string&, const std::string&);
145 
146 extern OCTAVE_API int
147 symlink (const std::string&, const std::string&, std::string&);
148 
149 extern OCTAVE_API int
150 readlink (const std::string&, std::string&);
151 
152 extern OCTAVE_API int
153 readlink (const std::string&, std::string&, std::string&);
154 
155 extern OCTAVE_API int
156 rename (const std::string&, const std::string&);
157 
158 extern OCTAVE_API int
159 rename (const std::string&, const std::string&, std::string&);
160 
161 extern OCTAVE_API int
162 rmdir (const std::string&);
163 
164 extern OCTAVE_API int
165 rmdir (const std::string&, std::string&);
166 
167 extern OCTAVE_API int
168 recursive_rmdir (const std::string&);
169 
170 extern OCTAVE_API int
171 recursive_rmdir (const std::string&, std::string&);
172 
173 extern OCTAVE_API int
174 umask (mode_t);
175 
176 extern OCTAVE_API int
177 unlink (const std::string&);
178 
179 extern OCTAVE_API int
180 unlink (const std::string&, std::string&);
181 
182 extern OCTAVE_API std::string
183 tempnam (const std::string&, const std::string&);
184 
185 extern OCTAVE_API std::string
186 tempnam (const std::string&, const std::string&, std::string&);
187 
188 extern OCTAVE_API std::string
189 canonicalize_file_name (const std::string&);
190 
191 extern OCTAVE_API std::string
192 canonicalize_file_name (const std::string&, std::string&);
193 
196 
197 #endif
OCTAVE_END_NAMESPACE(octave)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
OCTAVE_API bool is_dev_sep(char c)
Definition: file-ops.cc:266
OCTAVE_API int symlink(const std::string &, const std::string &)
Definition: file-ops.cc:512
OCTAVE_API string_vector tilde_additional_prefixes
Definition: file-ops.cc:262
OCTAVE_API std::string canonicalize_file_name(const std::string &)
Definition: file-ops.cc:744
OCTAVE_API int unlink(const std::string &)
Definition: file-ops.cc:677
OCTAVE_API int rename(const std::string &, const std::string &)
Definition: file-ops.cc:559
OCTAVE_API int rmdir(const std::string &)
Definition: file-ops.cc:586
OCTAVE_API int recursive_mkdir(const std::string &name, mode_t mode)
Definition: file-ops.cc:420
OCTAVE_API std::string dirname(const std::string &path)
Definition: file-ops.cc:360
OCTAVE_API int mkfifo(const std::string &, mode_t)
Definition: file-ops.cc:473
OCTAVE_API std::string concat(const std::string &, const std::string &)
Definition: file-ops.cc:351
OCTAVE_API char dev_sep_char(void)
Definition: file-ops.cc:222
OCTAVE_API int recursive_rmdir(const std::string &)
Definition: file-ops.cc:608
OCTAVE_API tilde_expansion_hook tilde_expansion_failure_hook
Definition: file-ops.cc:260
OCTAVE_API std::string tail(const std::string &path)
Definition: file-ops.cc:367
OCTAVE_API char dir_sep_char(void)
Definition: file-ops.cc:231
OCTAVE_API std::string dir_sep_str(void)
Definition: file-ops.cc:240
OCTAVE_API std::string dir_sep_chars(void)
Definition: file-ops.cc:249
OCTAVE_API int link(const std::string &, const std::string &)
Definition: file-ops.cc:491
OCTAVE_API tilde_expansion_hook tilde_expansion_preexpansion_hook
Definition: file-ops.cc:258
OCTAVE_API int mkdir(const std::string &, mode_t)
Definition: file-ops.cc:402
OCTAVE_API bool is_dir_sep(char c)
Definition: file-ops.cc:277
std::string(* tilde_expansion_hook)(const std::string &)
Definition: file-ops.h:43
OCTAVE_API string_vector tilde_additional_suffixes
Definition: file-ops.cc:264
OCTAVE_API std::string tempnam(const std::string &, const std::string &)
Definition: file-ops.cc:697
OCTAVE_API int umask(mode_t)
Definition: file-ops.cc:672
OCTAVE_API int readlink(const std::string &, std::string &)
Definition: file-ops.cc:533
OCTAVE_API std::string native_separator_path(const std::string &path)
Definition: file-ops.cc:379
OCTAVE_API std::string tilde_expand(const std::string &)
Definition: file-ops.cc:283
#define OCTAVE_API
Definition: main.in.cc:55