GNU Octave 11.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
file-ops.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2026 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
39
41
42typedef std::string (*tilde_expansion_hook) (const std::string&);
43
44// If non-null, this contains the address of a function that the
45// application wants called before trying the standard tilde
46// expansions. The function is called with the text sans tilde, and
47// returns a malloc()'ed string which is the expansion, or a NULL
48// pointer if the expansion fails.
49
51
52// If non-null, this contains the address of a function to call if the
53// standard meaning for expanding a tilde fails. The function is
54// called with the text (sans tilde, as in "foo"), and returns a
55// malloc()'ed string which is the expansion, or a NULL pointer if
56// there is no expansion.
57
59
60// When non-null, this is a NULL terminated array of strings which are
61// duplicates for a tilde prefix. Bash uses this to expand '=~' and
62// ':~'.
63
65
66// When non-null, this is a NULL terminated array of strings which
67// match the end of a username, instead of just "/". Bash sets this
68// to ':' and '=~'.
69
71
72// Find the start of a tilde expansion in S, and return the index
73// of the tilde which starts the expansion. Place the length of the
74// text which identified this tilde starter in LEN, excluding the
75// tilde itself.
76
77extern OCTAVE_API char dev_sep_char ();
78
79extern OCTAVE_API bool is_dev_sep (char c);
80
81extern OCTAVE_API char dir_sep_char ();
82
83extern OCTAVE_API std::string dir_sep_str ();
84
85extern OCTAVE_API std::string dir_sep_chars ();
86
87extern OCTAVE_API bool is_dir_sep (char c);
88
89// If NAME has a leading ~ or ~user, Unix-style, expand it to the
90// user's home directory. If no ~, or no <pwd.h>, just return NAME.
91
92extern OCTAVE_API std::string tilde_expand (const std::string&);
93
94// A vector version of the above.
95
97
98extern OCTAVE_API std::string concat (const std::string&, const std::string&);
99
100// Return the directory part of a filename or an empty string if
101// there is no directory component. Does not check to see
102// whether the file exists or is a directory.
103
104extern OCTAVE_API std::string dirname (const std::string& path);
105
106// Return the tail member of a filename.
107
108extern OCTAVE_API std::string tail (const std::string& path);
109
110// Convert path from UNIX type separators to whatever is the
111// system separators.
112
113extern OCTAVE_API std::string
114native_separator_path (const std::string& path);
115
116OCTAVE_END_NAMESPACE(file_ops)
117
118extern OCTAVE_API int
119mkdir (const std::string&, mode_t);
120
121extern OCTAVE_API int
122mkdir (const std::string&, mode_t, std::string&);
123
124extern OCTAVE_API int
125recursive_mkdir (const std::string& name, mode_t mode);
126
127extern OCTAVE_API int
128recursive_mkdir (const std::string& name, mode_t mode, std::string& msg);
129
130extern OCTAVE_API int
131mkfifo (const std::string&, mode_t);
132
133extern OCTAVE_API int
134mkfifo (const std::string&, mode_t, std::string&);
135
136extern OCTAVE_API int
137link (const std::string&, const std::string&);
138
139extern OCTAVE_API int
140link (const std::string&, const std::string&, std::string&);
141
142extern OCTAVE_API int
143symlink (const std::string&, const std::string&);
144
145extern OCTAVE_API int
146symlink (const std::string&, const std::string&, std::string&);
147
148extern OCTAVE_API int
149readlink (const std::string&, std::string&);
150
151extern OCTAVE_API int
152readlink (const std::string&, std::string&, std::string&);
153
154extern OCTAVE_API int
155rename (const std::string&, const std::string&);
156
157extern OCTAVE_API int
158rename (const std::string&, const std::string&, std::string&);
159
160extern OCTAVE_API int
161rmdir (const std::string&);
162
163extern OCTAVE_API int
164rmdir (const std::string&, std::string&);
165
166extern OCTAVE_API int
167recursive_rmdir (const std::string&);
168
169extern OCTAVE_API int
170recursive_rmdir (const std::string&, std::string&);
171
172extern OCTAVE_API int
173umask (mode_t);
174
175extern OCTAVE_API int
176unlink (const std::string&);
177
178extern OCTAVE_API int
179unlink (const std::string&, std::string&);
180
181extern OCTAVE_API std::string
182tempnam (const std::string&, const std::string&);
183
184extern OCTAVE_API std::string
185tempnam (const std::string&, const std::string&, std::string&);
186
187extern OCTAVE_API std::string
188canonicalize_file_name (const std::string&);
189
190extern OCTAVE_API std::string
191canonicalize_file_name (const std::string&, std::string&);
192
193OCTAVE_END_NAMESPACE(sys)
194OCTAVE_END_NAMESPACE(octave)
195
196#endif
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
bool is_dir_sep(char c)
Definition file-ops.cc:282
std::string canonicalize_file_name(const std::string &)
Definition file-ops.cc:868
int umask(mode_t)
Definition file-ops.cc:791
int recursive_rmdir(const std::string &)
Definition file-ops.cc:725
std::string tilde_expand(const std::string &)
Definition file-ops.cc:289
std::string dir_sep_str()
Definition file-ops.cc:242
std::string native_separator_path(const std::string &path)
Definition file-ops.cc:390
int rmdir(const std::string &)
Definition file-ops.cc:701
int mkfifo(const std::string &, mode_t)
Definition file-ops.cc:488
string_vector tilde_additional_suffixes
Definition file-ops.cc:267
std::string dir_sep_chars()
Definition file-ops.cc:252
int rename(const std::string &, const std::string &)
Definition file-ops.cc:582
int readlink(const std::string &, std::string &)
Definition file-ops.cc:554
int symlink(const std::string &, const std::string &)
Definition file-ops.cc:531
std::string dirname(const std::string &path)
Definition file-ops.cc:369
int link(const std::string &, const std::string &)
Definition file-ops.cc:508
bool is_dev_sep(char c)
Definition file-ops.cc:270
tilde_expansion_hook tilde_expansion_failure_hook
Definition file-ops.cc:263
std::string concat(const std::string &, const std::string &)
Definition file-ops.cc:359
std::string tempnam(const std::string &, const std::string &)
Definition file-ops.cc:819
char dir_sep_char()
Definition file-ops.cc:232
int mkdir(const std::string &, mode_t)
Definition file-ops.cc:413
std::string(* tilde_expansion_hook)(const std::string &)
Definition file-ops.h:42
tilde_expansion_hook tilde_expansion_preexpansion_hook
Definition file-ops.cc:261
int unlink(const std::string &)
Definition file-ops.cc:797
int recursive_mkdir(const std::string &name, mode_t mode)
Definition file-ops.cc:433
string_vector tilde_additional_prefixes
Definition file-ops.cc:265
char dev_sep_char()
Definition file-ops.cc:222
std::string tail(const std::string &path)
Definition file-ops.cc:377
#define OCTAVE_API
Definition main.in.cc:55