GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
file-ops.cc
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 (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <cerrno>
31 #include <cstdio>
32 #include <cstdlib>
33 #include <cstring>
34 
35 #include <vector>
36 
37 #if defined (OCTAVE_USE_WINDOWS_API)
38 # include <cctype>
39 
40 # include <windows.h>
41 # include "unwind-prot.h"
42 #else
44 #endif
45 
46 #include "areadlink-wrapper.h"
47 #include "dir-ops.h"
48 #include "file-ops.h"
49 #include "file-stat.h"
50 #include "gen-tempname-wrapper.h"
51 #include "lo-sysdep.h"
52 #include "oct-env.h"
53 #include "oct-locbuf.h"
54 #include "oct-password.h"
55 #include "quit.h"
56 #include "stat-wrappers.h"
57 #include "str-vec.h"
58 #include "unistd-wrappers.h"
59 
61 
62 // The following tilde-expansion code was stolen and adapted from
63 // readline.
64 
65 // The default value of tilde_additional_prefixes. This is set to
66 // whitespace preceding a tilde so that simple programs which do not
67 // perform any word separation get desired behavior.
68 static const char *default_prefixes[] = { " ~", "\t~", ":~", nullptr };
69 
70 // The default value of tilde_additional_suffixes. This is set to
71 // whitespace or newline so that simple programs which do not perform
72 // any word separation get desired behavior.
73 static const char *default_suffixes[] = { " ", "\n", ":", nullptr };
74 
75 static std::size_t
76 tilde_find_prefix (const std::string& s, std::size_t& len)
77 {
78  len = 0;
79 
80  std::size_t s_len = s.length ();
81 
82  if (s_len == 0 || s[0] == '~')
83  return 0;
84 
86 
87  if (! prefixes.empty ())
88  {
89  for (std::size_t i = 0; i < s_len; i++)
90  {
91  for (int j = 0; j < prefixes.numel (); j++)
92  {
93  std::size_t pfx_len = prefixes[j].length ();
94 
95  if (prefixes[j] == s.substr (i, pfx_len))
96  {
97  len = pfx_len - 1;
98  return i + len;
99  }
100  }
101  }
102  }
103 
104  return s_len;
105 }
106 
107 // Find the end of a tilde expansion in S, and return the index
108 // of the character which ends the tilde definition.
109 
110 static std::size_t
111 tilde_find_suffix (const std::string& s)
112 {
113  std::size_t s_len = s.length ();
114 
116 
117  std::size_t i = 0;
118 
119  for ( ; i < s_len; i++)
120  {
121  if (sys::file_ops::is_dir_sep (s[i]))
122  break;
123 
124  if (! suffixes.empty ())
125  {
126  for (int j = 0; j < suffixes.numel (); j++)
127  {
128  std::size_t sfx_len = suffixes[j].length ();
129 
130  if (suffixes[j] == s.substr (i, sfx_len))
131  return i;
132  }
133  }
134  }
135 
136  return i;
137 }
138 
139 // Take FNAME and return the tilde prefix we want expanded.
140 
141 static std::string
142 isolate_tilde_prefix (const std::string& fname)
143 {
144  std::size_t f_len = fname.length ();
145 
146  std::size_t len = 1;
147 
148  while (len < f_len && ! sys::file_ops::is_dir_sep (fname[len]))
149  len++;
150 
151  return fname.substr (1, len);
152 }
153 
154 // Do the work of tilde expansion on FILENAME. FILENAME starts with a
155 // tilde.
156 
157 static std::string
158 tilde_expand_word (const std::string& filename)
159 {
160  std::size_t f_len = filename.length ();
161 
162  if (f_len == 0 || filename[0] != '~')
163  return std::string (filename);
164 
165  // A leading '~/' or a bare '~' is *always* translated to the value
166  // of $HOME or the home directory of the current user, regardless of
167  // any preexpansion hook.
168 
169  if (f_len == 1 || sys::file_ops::is_dir_sep (filename[1]))
170  return sys::env::get_home_directory () + filename.substr (1);
171 
172  std::string username = isolate_tilde_prefix (filename);
173 
174  std::size_t user_len = username.length ();
175 
176  std::string dirname;
177 
179  {
180  std::string expansion
182 
183  if (! expansion.empty ())
184  return expansion + filename.substr (user_len+1);
185  }
186 
187  // No preexpansion hook, or the preexpansion hook failed. Look in the
188  // password database.
189 
190  sys::password pw = sys::password::getpwnam (username);
191 
192  if (! pw)
193  {
194  // If the calling program has a special syntax for expanding tildes,
195  // and we couldn't find a standard expansion, then let them try.
196 
198  {
199  std::string expansion
201 
202  if (! expansion.empty ())
203  dirname = expansion + filename.substr (user_len+1);
204  }
205 
206  // If we don't have a failure hook, or if the failure hook did not
207  // expand the tilde, return a copy of what we were passed.
208 
209  if (dirname.empty ())
210  dirname = filename;
211  }
212  else
213  dirname = pw.dir () + filename.substr (user_len+1);
214 
215  return dirname;
216 }
217 
219 
220 OCTAVE_BEGIN_NAMESPACE(file_ops)
221 
222 char dev_sep_char (void)
223 {
224 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
225  return ':';
226 #else
227  return 0;
228 #endif
229 }
230 
231 char dir_sep_char (void)
232 {
233 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
234  return '\\';
235 #else
236  return '/';
237 #endif
238 }
239 
240 std::string dir_sep_str (void)
241 {
242 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
243  return R"(\)";
244 #else
245  return "/";
246 #endif
247 }
248 
249 std::string dir_sep_chars (void)
250 {
251 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM)
252  return R"(/\)";
253 #else
254  return dir_sep_str ();
255 #endif
256 }
257 
259 
261 
263 
265 
266 bool is_dev_sep (char c)
267 {
268 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
269  return c == dev_sep_char ();
270 #else
271  octave_unused_parameter (c);
272 
273  return false;
274 #endif
275 }
276 
277 bool is_dir_sep (char c)
278 {
279  std::string tmp = dir_sep_chars ();
280  return tmp.find (c) != std::string::npos;
281 }
282 
283 std::string tilde_expand (const std::string& name)
284 {
285  if (name.find ('~') == std::string::npos)
286  return std::string (name);
287  else
288  {
289  std::string result;
290 
291  std::size_t name_len = name.length ();
292 
293  // Scan through S expanding tildes as we come to them.
294 
295  std::size_t pos = 0;
296 
297  while (1)
298  {
299  if (pos > name_len)
300  break;
301 
302  std::size_t len;
303 
304  // Make START point to the tilde which starts the expansion.
305 
306  std::size_t start = tilde_find_prefix (name.substr (pos), len);
307 
308  result.append (name.substr (pos, start));
309 
310  // Advance STRING to the starting tilde.
311 
312  pos += start;
313 
314  // Make FINI be the index of one after the last character of the
315  // username.
316 
317  std::size_t fini = tilde_find_suffix (name.substr (pos));
318 
319  // If both START and FINI are zero, we are all done.
320 
321  if (! (start || fini))
322  break;
323 
324  // Expand the entire tilde word, and copy it into RESULT.
325 
326  std::string tilde_word = name.substr (pos, fini);
327 
328  pos += fini;
329 
330  std::string expansion = tilde_expand_word (tilde_word);
331 
332  result.append (expansion);
333  }
334 
335  return result;
336  }
337 }
338 
340 {
341  int n = names.numel ();
342 
343  string_vector retval (n);
344 
345  for (int i = 0; i < n; i++)
346  retval[i] = tilde_expand (names[i]);
347 
348  return retval;
349 }
350 
351 std::string concat (const std::string& dir, const std::string& file)
352 {
353  return dir.empty ()
354  ? file
355  : (is_dir_sep (dir.back ())
356  ? dir + file
357  : dir + dir_sep_char () + file);
358 }
359 
360 std::string dirname (const std::string& path)
361 {
362  std::size_t ipos = path.find_last_of (dir_sep_chars ());
363 
364  return (ipos != std::string::npos) ? path.substr (0, ipos) : "";
365 }
366 
367 std::string tail (const std::string& path)
368 {
369  std::size_t ipos = path.find_last_of (dir_sep_chars ());
370 
371  if (ipos != std::string::npos)
372  ipos++;
373  else
374  ipos = 0;
375 
376  return path.substr (ipos);
377 }
378 
379 std::string native_separator_path (const std::string& path)
380 {
381  std::string retval;
382 
383  if (dir_sep_char () == '/')
384  retval = path;
385  else
386  {
387  std::size_t n = path.length ();
388  for (std::size_t i = 0; i < n; i++)
389  {
390  if (path[i] == '/')
391  retval += dir_sep_char();
392  else
393  retval += path[i];
394  }
395  }
396 
397  return retval;
398 }
399 
400 OCTAVE_END_NAMESPACE(file_ops)
401 
402 int mkdir (const std::string& nm, mode_t md)
403 {
404  std::string msg;
405  return mkdir (nm, md, msg);
406 }
407 
408 int mkdir (const std::string& name, mode_t mode, std::string& msg)
409 {
410  msg = "";
411 
412  int status = octave_mkdir_wrapper (name.c_str (), mode);
413 
414  if (status < 0)
415  msg = std::strerror (errno);
416 
417  return status;
418 }
419 
420 int recursive_mkdir (const std::string& name, mode_t mode)
421 {
422  std::string msg;
423  return recursive_mkdir (name, mode, msg);
424 }
425 
426 int recursive_mkdir (const std::string& name, mode_t mode, std::string& msg)
427 {
428  int status;
429 
430  // account for root in absolute directories
431 #if defined (OCTAVE_USE_WINDOWS_API)
432  // root of current drive
433  std::size_t skip_root = 0;
434  if (name.size () > 1)
435  {
436  if (name[1] == ':')
437  // drive root (e.g., C:\‍)
438  skip_root = 2;
439  else if (file_ops::is_dir_sep (name[0])
440  && file_ops::is_dir_sep (name[1]))
441  {
442  // UNC path root (e.g., \\SERVER\share\‍)
443  skip_root = name.find_first_of (file_ops::dir_sep_chars (), 2);
444  skip_root = name.find_first_of (file_ops::dir_sep_chars (),
445  skip_root + 1);
446  }
447  }
448 
449  std::size_t delim = name.find_first_of (file_ops::dir_sep_chars (),
450  skip_root + 1);
451 #else
452  std::size_t delim = name.find_first_of (file_ops::dir_sep_chars (), 1);
453 #endif
454 
455  // iterate over all componenents of NAME and make directories
456  while (delim != std::string::npos)
457  {
458  std::string base = name.substr (0, delim);
459  sys::file_stat fs (base);
460  if (! fs.is_dir ())
461  {
462  status = mkdir (base, mode, msg);
463  if (status < 0)
464  return status;
465  }
466  delim = name.find_first_of (file_ops::dir_sep_chars (), delim + 1);
467  }
468 
469  // finally, create requested directory
470  return mkdir (name, mode, msg);
471 }
472 
473 int mkfifo (const std::string& nm, mode_t md)
474 {
475  std::string msg;
476  return mkfifo (nm, md, msg);
477 }
478 
479 int mkfifo (const std::string& name, mode_t mode, std::string& msg)
480 {
481  msg = "";
482 
483  int status = octave_mkfifo_wrapper (name.c_str (), mode);
484 
485  if (status < 0)
486  msg = std::strerror (errno);
487 
488  return status;
489 }
490 
491 int link (const std::string& old_name, const std::string& new_name)
492 {
493  std::string msg;
494  return link (old_name, new_name, msg);
495 }
496 
497 int link (const std::string& old_name, const std::string& new_name,
498  std::string& msg)
499 {
500  msg = "";
501 
502  int status = -1;
503 
504  status = octave_link_wrapper (old_name.c_str (), new_name.c_str ());
505 
506  if (status < 0)
507  msg = std::strerror (errno);
508 
509  return status;
510 }
511 
512 int symlink (const std::string& old_name, const std::string& new_name)
513 {
514  std::string msg;
515  return symlink (old_name, new_name, msg);
516 }
517 
518 int symlink (const std::string& old_name, const std::string& new_name,
519  std::string& msg)
520 {
521  msg = "";
522 
523  int status = -1;
524 
525  status = octave_symlink_wrapper (old_name.c_str (), new_name.c_str ());
526 
527  if (status < 0)
528  msg = std::strerror (errno);
529 
530  return status;
531 }
532 
533 int readlink (const std::string& path, std::string& result)
534 {
535  std::string msg;
536  return readlink (path, result, msg);
537 }
538 
539 int readlink (const std::string& path, std::string& result, std::string& msg)
540 {
541  int status = -1;
542 
543  msg = "";
544 
545  char *buf = octave_areadlink_wrapper (path.c_str ());
546 
547  if (! buf)
548  msg = std::strerror (errno);
549  else
550  {
551  result = buf;
552  ::free (buf);
553  status = 0;
554  }
555 
556  return status;
557 }
558 
559 int rename (const std::string& from, const std::string& to)
560 {
561  std::string msg;
562  return rename (from, to, msg);
563 }
564 
565 int rename (const std::string& from, const std::string& to,
566  std::string& msg)
567 {
568  int status = -1;
569 
570  msg = "";
571 
572 #if defined (OCTAVE_USE_WINDOWS_API)
573  std::wstring wfrom = u8_to_wstring (from);
574  std::wstring wto = u8_to_wstring (to);
575  status = _wrename (wfrom.c_str (), wto.c_str ());
576 #else
577  status = std::rename (from.c_str (), to.c_str ());
578 #endif
579 
580  if (status < 0)
581  msg = std::strerror (errno);
582 
583  return status;
584 }
585 
586 int rmdir (const std::string& name)
587 {
588  std::string msg;
589  return rmdir (name, msg);
590 }
591 
592 int rmdir (const std::string& name, std::string& msg)
593 {
594  msg = "";
595 
596  int status = -1;
597 
598  status = octave_rmdir_wrapper (name.c_str ());
599 
600  if (status < 0)
601  msg = std::strerror (errno);
602 
603  return status;
604 }
605 
606 // And a version that works recursively.
607 
608 int recursive_rmdir (const std::string& name)
609 {
610  std::string msg;
611  return recursive_rmdir (name, msg);
612 }
613 
614 int recursive_rmdir (const std::string& name, std::string& msg)
615 {
616  msg = "";
617 
618  int status = 0;
619 
620  string_vector dirlist;
621 
622  if (get_dirlist (name, dirlist, msg))
623  {
624  for (octave_idx_type i = 0; i < dirlist.numel (); i++)
625  {
626  octave_quit ();
627 
628  std::string nm = dirlist[i];
629 
630  // Skip current directory and parent.
631  if (nm == "." || nm == "..")
632  continue;
633 
634  std::string fullnm = name + file_ops::dir_sep_str () + nm;
635 
636  // Get info about the file. Don't follow links.
637  file_stat fs (fullnm, false);
638 
639  if (fs)
640  {
641  if (fs.is_dir ())
642  {
643  status = recursive_rmdir (fullnm, msg);
644 
645  if (status < 0)
646  break;
647  }
648  else
649  {
650  status = unlink (fullnm, msg);
651 
652  if (status < 0)
653  break;
654  }
655  }
656  else
657  {
658  msg = fs.error ();
659  break;
660  }
661  }
662 
663  if (status >= 0)
664  status = rmdir (name, msg);
665  }
666  else
667  status = -1;
668 
669  return status;
670 }
671 
672 int umask (mode_t mode)
673 {
674  return octave_umask_wrapper (mode);
675 }
676 
677 int unlink (const std::string& name)
678 {
679  std::string msg;
680  return unlink (name, msg);
681 }
682 
683 int unlink (const std::string& name, std::string& msg)
684 {
685  msg = "";
686 
687  int status = -1;
688 
689  status = octave_unlink_wrapper (name.c_str ());
690 
691  if (status < 0)
692  msg = std::strerror (errno);
693 
694  return status;
695 }
696 
697 std::string tempnam (const std::string& dir, const std::string& pfx)
698 {
699  std::string msg;
700  return tempnam (dir, pfx, msg);
701 }
702 
703 std::string tempnam (const std::string& dir, const std::string& pfx,
704  std::string& msg)
705 {
706  msg = "";
707 
708  std::string retval;
709 
710  // get dir path to use for template
711  std::string templatename;
712  if (dir.empty ())
713  templatename = env::get_temp_directory ();
714  else if (! file_stat (dir, false).is_dir ())
715  templatename = env::get_temp_directory ();
716  else
717  templatename = dir;
718 
719  // add dir sep char if it is not there
720  if (*templatename.rbegin () != file_ops::dir_sep_char ())
721  templatename += file_ops::dir_sep_char ();
722 
723  if (pfx.empty ())
724  templatename += "file";
725  else
726  templatename += pfx;
727 
728  // add the required XXXXXX for the template
729  templatename += "XXXXXX";
730 
731  // create and copy template to char array for call to gen_tempname
732  char tname [templatename.length () + 1];
733 
734  strcpy (tname, templatename.c_str ());
735 
736  if (octave_gen_tempname_wrapper (tname) == -1)
737  msg = std::strerror (errno);
738  else
739  retval = tname;
740 
741  return retval;
742 }
743 
744 std::string canonicalize_file_name (const std::string& name)
745 {
746  std::string msg;
747  return canonicalize_file_name (name, msg);
748 }
749 
750 std::string canonicalize_file_name (const std::string& name, std::string& msg)
751 {
752  msg = "";
753 
754  std::string retval;
755 
756  // FIXME: Consider replacing this with std::filesystem::canonical on all
757  // platforms once we allow using C++17.
758 
759 #if defined (OCTAVE_USE_WINDOWS_API)
760  // open file handle
761  std::wstring wname = u8_to_wstring (name);
762  HANDLE h_file = CreateFileW (wname.c_str (), GENERIC_READ,
763  FILE_SHARE_READ, nullptr, OPEN_EXISTING,
764  FILE_FLAG_BACKUP_SEMANTICS, nullptr);
765 
766  // Might have been a symbolic link that points to a network share.
767  // It looks like opening a network share itself (not a file or folder
768  // *on* a share) might return an invalid handle. As a workaround, try to
769  // open a handle to the symbolic link itself (and do not resolve it).
770  if (h_file == INVALID_HANDLE_VALUE)
771  h_file = CreateFileW (wname.c_str (), GENERIC_READ,
772  FILE_SHARE_READ, nullptr, OPEN_EXISTING,
773  FILE_FLAG_BACKUP_SEMANTICS
774  | FILE_FLAG_OPEN_REPARSE_POINT, nullptr);
775 
776  if (h_file == INVALID_HANDLE_VALUE)
777  {
778  msg = "Unable to open file \"" + name + "\"";
779  return retval;
780  }
781 
782  unwind_action close_file_handle (CloseHandle, h_file);
783 
784  const std::size_t buf_size = 32767;
785  wchar_t buffer[buf_size] = L"";
786 
787  // query canonical name
788  DWORD len = GetFinalPathNameByHandleW (h_file, buffer, buf_size,
789  FILE_NAME_NORMALIZED);
790  if (len >= buf_size)
791  {
792  msg = "Error querying normalized name for \"" + name + "\"";
793  return retval;
794  }
795 
796  retval = u8_from_wstring (std::wstring (buffer, len));
797 
798  // remove prefix
799  // "Normal" paths are prefixed by "\\?\".
800  // UNC paths are prefixed by "\\?\UNC\".
801  if (retval.compare (0, 8, R"(\\?\UNC\)") == 0)
802  {
803  retval = retval.erase (2, 6);
804 
805  // If the initial path looked like a mapped network drive, replace
806  // portion of path that corresponds to mapped root with drive root.
807  if (name.size () < 3 || name[1] != ':')
808  return retval;
809 
810  // UNC path corresponding to original drive letter (mappped drive)
811  std::wstring orig_map = wname.substr (0, 3);
812  orig_map[2] = L'\\';
813  HANDLE h_map = CreateFileW (orig_map.c_str (), GENERIC_READ,
814  FILE_SHARE_READ, nullptr, OPEN_EXISTING,
815  FILE_FLAG_BACKUP_SEMANTICS
816  | FILE_FLAG_OPEN_REPARSE_POINT,
817  nullptr);
818 
819  if (h_map == INVALID_HANDLE_VALUE)
820  // cannot determine common root
821  return retval;
822 
823  unwind_action close_map_handle (CloseHandle, h_map);
824  len = GetFinalPathNameByHandleW (h_map, buffer, buf_size,
825  FILE_NAME_NORMALIZED);
826 
827  std::string orig_root
828  = u8_from_wstring (std::wstring (buffer, len));
829 
830  if (orig_root.compare (0, 8, R"(\\?\UNC\)"))
831  // root was not a mapped share
832  return retval;
833 
834  orig_root = orig_root.erase (2, 6);
835  // trim trailing file separators from UNC path corresponding to root
836  std::string file_seps = file_ops::dir_sep_chars ();
837  while (file_seps.find (orig_root.back ()) != std::string::npos)
838  orig_root.pop_back ();
839 
840  if (retval.compare (0, orig_root.size (), orig_root))
841  // start of UNC path doesn't match mapped drive root
842  return retval;
843 
844  // file is on mapped share
845  size_t sep_pos = orig_root.size ();
846  if (sep_pos != retval.size ())
847  retval = retval.substr (sep_pos-2);
848  else
849  retval.resize (2); // no file component
850  retval[0] = std::toupper (name[0]);
851  retval[1] = ':';
852  }
853  else if (retval.compare (0, 4, R"(\\?\)") == 0)
854  retval = retval.erase (0, 4);
855 #else
856  char *tmp = octave_canonicalize_file_name_wrapper (name.c_str ());
857 
858  if (tmp)
859  {
860  retval = tmp;
861  free (tmp);
862  }
863 
864  if (retval.empty ())
865  msg = std::strerror (errno);
866 #endif
867 
868  return retval;
869 }
870 
OCTAVE_END_NAMESPACE(octave)
char * octave_canonicalize_file_name_wrapper(const char *name)
bool is_dir(void) const
Definition: file-stat.cc:65
std::string error(void) const
Definition: file-stat.h:149
static std::string get_temp_directory(void)
Definition: oct-env.cc:152
octave_idx_type numel(void) const
Definition: str-vec.h:100
bool empty(void) const
Definition: str-vec.h:77
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
int unlink(const std::string &name)
Definition: file-ops.cc:677
bool is_dir_sep(char c)
Definition: file-ops.cc:277
static std::size_t tilde_find_suffix(const std::string &s)
Definition: file-ops.cc:111
char dev_sep_char(void)
Definition: file-ops.cc:222
static std::string isolate_tilde_prefix(const std::string &fname)
Definition: file-ops.cc:142
int rename(const std::string &from, const std::string &to)
Definition: file-ops.cc:559
static const char * default_suffixes[]
Definition: file-ops.cc:73
static std::string tilde_expand_word(const std::string &filename)
Definition: file-ops.cc:158
int symlink(const std::string &old_name, const std::string &new_name)
Definition: file-ops.cc:512
std::string concat(const std::string &dir, const std::string &file)
Definition: file-ops.cc:351
std::string canonicalize_file_name(const std::string &name)
Definition: file-ops.cc:744
int readlink(const std::string &path, std::string &result)
Definition: file-ops.cc:533
std::string native_separator_path(const std::string &path)
Definition: file-ops.cc:379
string_vector tilde_additional_suffixes
Definition: file-ops.cc:264
int rmdir(const std::string &name)
Definition: file-ops.cc:586
static const char * default_prefixes[]
Definition: file-ops.cc:68
int mkfifo(const std::string &nm, mode_t md)
Definition: file-ops.cc:473
std::string tempnam(const std::string &dir, const std::string &pfx)
Definition: file-ops.cc:697
std::string dirname(const std::string &path)
Definition: file-ops.cc:360
char dir_sep_char(void)
Definition: file-ops.cc:231
bool is_dev_sep(char c)
Definition: file-ops.cc:266
tilde_expansion_hook tilde_expansion_failure_hook
Definition: file-ops.cc:260
std::string dir_sep_chars(void)
Definition: file-ops.cc:249
static std::size_t tilde_find_prefix(const std::string &s, std::size_t &len)
Definition: file-ops.cc:76
int link(const std::string &old_name, const std::string &new_name)
Definition: file-ops.cc:491
std::string dir_sep_str(void)
Definition: file-ops.cc:240
tilde_expansion_hook tilde_expansion_preexpansion_hook
Definition: file-ops.cc:258
int recursive_mkdir(const std::string &name, mode_t mode)
Definition: file-ops.cc:420
string_vector tilde_additional_prefixes
Definition: file-ops.cc:262
int recursive_rmdir(const std::string &name)
Definition: file-ops.cc:608
int mkdir(const std::string &nm, mode_t md)
Definition: file-ops.cc:402
std::string tilde_expand(const std::string &name)
Definition: file-ops.cc:283
int umask(mode_t mode)
Definition: file-ops.cc:672
std::string tail(const std::string &path)
Definition: file-ops.cc:367
std::string(* tilde_expansion_hook)(const std::string &)
Definition: file-ops.h:43
int octave_gen_tempname_wrapper(char *tmpl)
std::string u8_from_wstring(const std::wstring &wchar_string)
Definition: lo-sysdep.cc:537
std::wstring u8_to_wstring(const std::string &utf8_string)
Definition: lo-sysdep.cc:514
bool get_dirlist(const std::string &dirname, string_vector &dirlist, std::string &msg)
Definition: lo-sysdep.cc:119
octave_idx_type n
Definition: mx-inlines.cc:753
void free(void *)
int octave_mkdir_wrapper(const char *name, mode_t mode)
Definition: stat-wrappers.c:49
int octave_mkfifo_wrapper(const char *name, mode_t mode)
Definition: stat-wrappers.c:63
int octave_umask_wrapper(mode_t mode)
Definition: stat-wrappers.c:69
int octave_rmdir_wrapper(const char *nm)
int octave_unlink_wrapper(const char *nm)
int octave_symlink_wrapper(const char *nm1, const char *nm2)
int octave_link_wrapper(const char *nm1, const char *nm2)
F77_RET_T len
Definition: xerbla.cc:61