GNU Octave 10.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-2025 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
42
43typedef 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
78extern OCTAVE_API char dev_sep_char ();
79
80extern OCTAVE_API bool is_dev_sep (char c);
81
82extern OCTAVE_API char dir_sep_char ();
83
84extern OCTAVE_API std::string dir_sep_str ();
85
86extern OCTAVE_API std::string dir_sep_chars ();
87
88extern 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
93extern OCTAVE_API std::string tilde_expand (const std::string&);
94
95// A vector version of the above.
96
98
99extern 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
105extern OCTAVE_API std::string dirname (const std::string& path);
106
107// Return the tail member of a filename.
108
109extern 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
114extern OCTAVE_API std::string
115native_separator_path (const std::string& path);
116
117OCTAVE_END_NAMESPACE(file_ops)
118
119extern OCTAVE_API int
120mkdir (const std::string&, mode_t);
121
122extern OCTAVE_API int
123mkdir (const std::string&, mode_t, std::string&);
124
125extern OCTAVE_API int
126recursive_mkdir (const std::string& name, mode_t mode);
127
128extern OCTAVE_API int
129recursive_mkdir (const std::string& name, mode_t mode, std::string& msg);
130
131extern OCTAVE_API int
132mkfifo (const std::string&, mode_t);
133
134extern OCTAVE_API int
135mkfifo (const std::string&, mode_t, std::string&);
136
137extern OCTAVE_API int
138link (const std::string&, const std::string&);
139
140extern OCTAVE_API int
141link (const std::string&, const std::string&, std::string&);
142
143extern OCTAVE_API int
144symlink (const std::string&, const std::string&);
145
146extern OCTAVE_API int
147symlink (const std::string&, const std::string&, std::string&);
148
149extern OCTAVE_API int
150readlink (const std::string&, std::string&);
151
152extern OCTAVE_API int
153readlink (const std::string&, std::string&, std::string&);
154
155extern OCTAVE_API int
156rename (const std::string&, const std::string&);
157
158extern OCTAVE_API int
159rename (const std::string&, const std::string&, std::string&);
160
161extern OCTAVE_API int
162rmdir (const std::string&);
163
164extern OCTAVE_API int
165rmdir (const std::string&, std::string&);
166
167extern OCTAVE_API int
168recursive_rmdir (const std::string&);
169
170extern OCTAVE_API int
171recursive_rmdir (const std::string&, std::string&);
172
173extern OCTAVE_API int
174umask (mode_t);
175
176extern OCTAVE_API int
177unlink (const std::string&);
178
179extern OCTAVE_API int
180unlink (const std::string&, std::string&);
181
182extern OCTAVE_API std::string
183tempnam (const std::string&, const std::string&);
184
185extern OCTAVE_API std::string
186tempnam (const std::string&, const std::string&, std::string&);
187
188extern OCTAVE_API std::string
189canonicalize_file_name (const std::string&);
190
191extern OCTAVE_API std::string
192canonicalize_file_name (const std::string&, std::string&);
193
194OCTAVE_END_NAMESPACE(sys)
195OCTAVE_END_NAMESPACE(octave)
196
197#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:798
int umask(mode_t)
Definition file-ops.cc:721
int recursive_rmdir(const std::string &)
Definition file-ops.cc:655
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:631
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:749
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:43
tilde_expansion_hook tilde_expansion_preexpansion_hook
Definition file-ops.cc:261
int unlink(const std::string &)
Definition file-ops.cc:727
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