GNU Octave  9.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-2024 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 ();
79 
80 extern OCTAVE_API bool is_dev_sep (char c);
81 
82 extern OCTAVE_API char dir_sep_char ();
83 
84 extern OCTAVE_API std::string dir_sep_str ();
85 
86 extern OCTAVE_API std::string dir_sep_chars ();
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 
194 OCTAVE_END_NAMESPACE(sys)
195 OCTAVE_END_NAMESPACE(octave)
196 
197 #endif
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
bool is_dir_sep(char c)
std::string canonicalize_file_name(const std::string &)
int umask(mode_t)
int recursive_rmdir(const std::string &)
std::string tilde_expand(const std::string &)
std::string dir_sep_str()
std::string native_separator_path(const std::string &path)
int rmdir(const std::string &)
int mkfifo(const std::string &, mode_t)
string_vector tilde_additional_suffixes
std::string dir_sep_chars()
int rename(const std::string &, const std::string &)
int readlink(const std::string &, std::string &)
int symlink(const std::string &, const std::string &)
std::string dirname(const std::string &path)
int link(const std::string &, const std::string &)
bool is_dev_sep(char c)
tilde_expansion_hook tilde_expansion_failure_hook
std::string concat(const std::string &, const std::string &)
std::string tempnam(const std::string &, const std::string &)
char dir_sep_char()
int mkdir(const std::string &, mode_t)
std::string(* tilde_expansion_hook)(const std::string &)
Definition: file-ops.h:43
tilde_expansion_hook tilde_expansion_preexpansion_hook
int unlink(const std::string &)
int recursive_mkdir(const std::string &name, mode_t mode)
string_vector tilde_additional_prefixes
char dev_sep_char()
std::string tail(const std::string &path)
#define OCTAVE_API
Definition: main.cc:55