GNU Octave 7.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-2022 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
37namespace octave
38{
39 namespace sys
40 {
41 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
118 extern OCTAVE_API int
119 mkdir (const std::string&, mode_t);
120
121 extern OCTAVE_API int
122 mkdir (const std::string&, mode_t, std::string&);
123
124 extern OCTAVE_API int
125 mkfifo (const std::string&, mode_t);
126
127 extern OCTAVE_API int
128 mkfifo (const std::string&, mode_t, std::string&);
129
130 extern OCTAVE_API int
131 link (const std::string&, const std::string&);
132
133 extern OCTAVE_API int
134 link (const std::string&, const std::string&, std::string&);
135
136 extern OCTAVE_API int
137 symlink (const std::string&, const std::string&);
138
139 extern OCTAVE_API int
140 symlink (const std::string&, const std::string&, std::string&);
141
142 extern OCTAVE_API int
143 readlink (const std::string&, std::string&);
144
145 extern OCTAVE_API int
146 readlink (const std::string&, std::string&, std::string&);
147
148 extern OCTAVE_API int
149 rename (const std::string&, const std::string&);
150
151 extern OCTAVE_API int
152 rename (const std::string&, const std::string&, std::string&);
153
154 extern OCTAVE_API int
155 rmdir (const std::string&);
156
157 extern OCTAVE_API int
158 rmdir (const std::string&, std::string&);
159
160 extern OCTAVE_API int
161 recursive_rmdir (const std::string&);
162
163 extern OCTAVE_API int
164 recursive_rmdir (const std::string&, std::string&);
165
166 extern OCTAVE_API int
167 umask (mode_t);
168
169 extern OCTAVE_API int
170 unlink (const std::string&);
171
172 extern OCTAVE_API int
173 unlink (const std::string&, std::string&);
174
175 extern OCTAVE_API std::string
176 tempnam (const std::string&, const std::string&);
177
178 extern OCTAVE_API std::string
179 tempnam (const std::string&, const std::string&, std::string&);
180
181 extern OCTAVE_API std::string
182 canonicalize_file_name (const std::string&);
183
184 extern OCTAVE_API std::string
185 canonicalize_file_name (const std::string&, std::string&);
186 }
187}
188
189#endif
QString path
#define OCTAVE_API
Definition: main.in.cc:55
std::string native_separator_path(const std::string &path)
Definition: file-ops.cc:377
string_vector tilde_additional_suffixes
Definition: file-ops.cc:262
tilde_expansion_hook tilde_expansion_failure_hook
Definition: file-ops.cc:258
std::string concat(const std::string &dir, const std::string &file)
Definition: file-ops.cc:349
std::string dirname(const std::string &path)
Definition: file-ops.cc:358
std::string(* tilde_expansion_hook)(const std::string &)
Definition: file-ops.h:43
std::string tilde_expand(const std::string &name)
Definition: file-ops.cc:281
char dev_sep_char(void)
Definition: file-ops.cc:220
char dir_sep_char(void)
Definition: file-ops.cc:229
std::string dir_sep_chars(void)
Definition: file-ops.cc:247
std::string dir_sep_str(void)
Definition: file-ops.cc:238
tilde_expansion_hook tilde_expansion_preexpansion_hook
Definition: file-ops.cc:256
bool is_dev_sep(char c)
Definition: file-ops.cc:264
std::string tail(const std::string &path)
Definition: file-ops.cc:365
bool is_dir_sep(char c)
Definition: file-ops.cc:275
string_vector tilde_additional_prefixes
Definition: file-ops.cc:260
int link(const std::string &old_name, const std::string &new_name)
Definition: file-ops.cc:435
std::string tempnam(const std::string &dir, const std::string &pfx)
Definition: file-ops.cc:641
int readlink(const std::string &path, std::string &result)
Definition: file-ops.cc:477
std::string canonicalize_file_name(const std::string &name)
Definition: file-ops.cc:688
int rename(const std::string &from, const std::string &to)
Definition: file-ops.cc:503
int mkdir(const std::string &nm, mode_t md)
Definition: file-ops.cc:399
int symlink(const std::string &old_name, const std::string &new_name)
Definition: file-ops.cc:456
int rmdir(const std::string &name)
Definition: file-ops.cc:530
int recursive_rmdir(const std::string &name)
Definition: file-ops.cc:552
int umask(mode_t mode)
Definition: file-ops.cc:616
int unlink(const std::string &name)
Definition: file-ops.cc:621
int mkfifo(const std::string &nm, mode_t md)
Definition: file-ops.cc:417