GNU Octave  9.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-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 (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 
221 
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
233 {
234 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
235  return '\\';
236 #else
237  return '/';
238 #endif
239 }
240 
241 std::string
243 {
244 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
245  return R"(\)";
246 #else
247  return "/";
248 #endif
249 }
250 
251 std::string
253 {
254 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM)
255  return R"(/\)";
256 #else
257  return dir_sep_str ();
258 #endif
259 }
260 
262 
264 
266 
268 
269 bool
270 is_dev_sep (char c)
271 {
272 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM))
273  return c == dev_sep_char ();
274 #else
275  octave_unused_parameter (c);
276 
277  return false;
278 #endif
279 }
280 
281 bool
282 is_dir_sep (char c)
283 {
284  std::string tmp = dir_sep_chars ();
285  return tmp.find (c) != std::string::npos;
286 }
287 
288 std::string
289 tilde_expand (const std::string& name)
290 {
291  if (name.find ('~') == std::string::npos)
292  return std::string (name);
293  else
294  {
295  std::string result;
296 
297  std::size_t name_len = name.length ();
298 
299  // Scan through S expanding tildes as we come to them.
300 
301  std::size_t pos = 0;
302 
303  while (1)
304  {
305  if (pos > name_len)
306  break;
307 
308  std::size_t len;
309 
310  // Make START point to the tilde which starts the expansion.
311 
312  std::size_t start = tilde_find_prefix (name.substr (pos), len);
313 
314  result.append (name.substr (pos, start));
315 
316  // Advance STRING to the starting tilde.
317 
318  pos += start;
319 
320  // Make FINI be the index of one after the last character of the
321  // username.
322 
323  std::size_t fini = tilde_find_suffix (name.substr (pos));
324 
325  // If both START and FINI are zero, we are all done.
326 
327  if (! (start || fini))
328  break;
329 
330  // Expand the entire tilde word, and copy it into RESULT.
331 
332  std::string tilde_word = name.substr (pos, fini);
333 
334  pos += fini;
335 
336  std::string expansion = tilde_expand_word (tilde_word);
337 
338  result.append (expansion);
339  }
340 
341  return result;
342  }
343 }
344 
347 {
348  int n = names.numel ();
349 
350  string_vector retval (n);
351 
352  for (int i = 0; i < n; i++)
353  retval[i] = tilde_expand (names[i]);
354 
355  return retval;
356 }
357 
358 std::string
359 concat (const std::string& dir, const std::string& file)
360 {
361  return dir.empty ()
362  ? file
363  : (is_dir_sep (dir.back ())
364  ? dir + file
365  : dir + dir_sep_char () + file);
366 }
367 
368 std::string
369 dirname (const std::string& path)
370 {
371  std::size_t ipos = path.find_last_of (dir_sep_chars ());
372 
373  return (ipos != std::string::npos) ? path.substr (0, ipos) : "";
374 }
375 
376 std::string
377 tail (const std::string& path)
378 {
379  std::size_t ipos = path.find_last_of (dir_sep_chars ());
380 
381  if (ipos != std::string::npos)
382  ipos++;
383  else
384  ipos = 0;
385 
386  return path.substr (ipos);
387 }
388 
389 std::string
390 native_separator_path (const std::string& path)
391 {
392  std::string retval;
393 
394  if (dir_sep_char () == '/')
395  retval = path;
396  else
397  {
398  std::size_t n = path.length ();
399  for (std::size_t i = 0; i < n; i++)
400  {
401  if (path[i] == '/')
402  retval += dir_sep_char();
403  else
404  retval += path[i];
405  }
406  }
407 
408  return retval;
409 }
410 
411 OCTAVE_END_NAMESPACE(file_ops)
412 
413 int mkdir (const std::string& nm, mode_t md)
414 {
415  std::string msg;
416  return mkdir (nm, md, msg);
417 }
418 
419 int
420 mkdir (const std::string& name, mode_t mode, std::string& msg)
421 {
422  msg = "";
423 
424  int status = octave_mkdir_wrapper (name.c_str (), mode);
425 
426  if (status < 0)
427  msg = std::strerror (errno);
428 
429  return status;
430 }
431 
432 int
433 recursive_mkdir (const std::string& name, mode_t mode)
434 {
435  std::string msg;
436  return recursive_mkdir (name, mode, msg);
437 }
438 
439 int
440 recursive_mkdir (const std::string& name, mode_t mode, std::string& msg)
441 {
442  int status;
443 
444  // account for root in absolute directories
445 #if defined (OCTAVE_USE_WINDOWS_API)
446  // root of current drive
447  std::size_t skip_root = 0;
448  if (name.size () > 1)
449  {
450  if (name[1] == ':')
451  // drive root (e.g., C:\‍)
452  skip_root = 2;
453  else if (file_ops::is_dir_sep (name[0])
454  && file_ops::is_dir_sep (name[1]))
455  {
456  // UNC path root (e.g., \\SERVER\share\‍)
457  skip_root = name.find_first_of (file_ops::dir_sep_chars (), 2);
458  skip_root = name.find_first_of (file_ops::dir_sep_chars (),
459  skip_root + 1);
460  }
461  }
462 
463  std::size_t delim = name.find_first_of (file_ops::dir_sep_chars (),
464  skip_root + 1);
465 #else
466  std::size_t delim = name.find_first_of (file_ops::dir_sep_chars (), 1);
467 #endif
468 
469  // iterate over all componenents of NAME and make directories
470  while (delim != std::string::npos)
471  {
472  std::string base = name.substr (0, delim);
473  sys::file_stat fs (base);
474  if (! fs.is_dir ())
475  {
476  status = mkdir (base, mode, msg);
477  if (status < 0)
478  return status;
479  }
480  delim = name.find_first_of (file_ops::dir_sep_chars (), delim + 1);
481  }
482 
483  // finally, create requested directory
484  return mkdir (name, mode, msg);
485 }
486 
487 int
488 mkfifo (const std::string& nm, mode_t md)
489 {
490  std::string msg;
491  return mkfifo (nm, md, msg);
492 }
493 
494 int
495 mkfifo (const std::string& name, mode_t mode, std::string& msg)
496 {
497  msg = "";
498 
499  int status = octave_mkfifo_wrapper (name.c_str (), mode);
500 
501  if (status < 0)
502  msg = std::strerror (errno);
503 
504  return status;
505 }
506 
507 int
508 link (const std::string& old_name, const std::string& new_name)
509 {
510  std::string msg;
511  return link (old_name, new_name, msg);
512 }
513 
514 int
515 link (const std::string& old_name, const std::string& new_name,
516  std::string& msg)
517 {
518  msg = "";
519 
520  int status = -1;
521 
522  status = octave_link_wrapper (old_name.c_str (), new_name.c_str ());
523 
524  if (status < 0)
525  msg = std::strerror (errno);
526 
527  return status;
528 }
529 
530 int
531 symlink (const std::string& old_name, const std::string& new_name)
532 {
533  std::string msg;
534  return symlink (old_name, new_name, msg);
535 }
536 
537 int
538 symlink (const std::string& old_name, const std::string& new_name,
539  std::string& msg)
540 {
541  msg = "";
542 
543  int status = -1;
544 
545  status = octave_symlink_wrapper (old_name.c_str (), new_name.c_str ());
546 
547  if (status < 0)
548  msg = std::strerror (errno);
549 
550  return status;
551 }
552 
553 int
554 readlink (const std::string& path, std::string& result)
555 {
556  std::string msg;
557  return readlink (path, result, msg);
558 }
559 
560 int
561 readlink (const std::string& path, std::string& result, std::string& msg)
562 {
563  int status = -1;
564 
565  msg = "";
566 
567  char *buf = octave_areadlink_wrapper (path.c_str ());
568 
569  if (! buf)
570  msg = std::strerror (errno);
571  else
572  {
573  result = buf;
574  ::free (buf);
575  status = 0;
576  }
577 
578  return status;
579 }
580 
581 int
582 rename (const std::string& from, const std::string& to)
583 {
584  std::string msg;
585  return rename (from, to, msg);
586 }
587 
588 int
589 rename (const std::string& from, const std::string& to,
590  std::string& msg)
591 {
592  int status = -1;
593 
594  msg = "";
595 
596  // Do nothing if source and target are the same file.
597  if (same_file (to, from))
598  return 0;
599 
600  // The behavior of std::rename with existing target is not defined by the
601  // standard. Implementations differ vastly. For Octave, use the following
602  // for the case that the target already exists:
603  // If the source and the target are regular files, overwrite the target.
604  // In other cases, fail.
605  if (file_exists (to))
606  {
607  if (file_exists (to, false) && file_exists (from, false))
608  unlink (to);
609  else
610  {
611  msg = "Target already exists.";
612  return status;
613  }
614  }
615 
616 #if defined (OCTAVE_USE_WINDOWS_API)
617  std::wstring wfrom = u8_to_wstring (from);
618  std::wstring wto = u8_to_wstring (to);
619  status = _wrename (wfrom.c_str (), wto.c_str ());
620 #else
621  status = std::rename (from.c_str (), to.c_str ());
622 #endif
623 
624  if (status < 0)
625  msg = std::strerror (errno);
626 
627  return status;
628 }
629 
630 int
631 rmdir (const std::string& name)
632 {
633  std::string msg;
634  return rmdir (name, msg);
635 }
636 
637 int
638 rmdir (const std::string& name, std::string& msg)
639 {
640  msg = "";
641 
642  int status = -1;
643 
644  status = octave_rmdir_wrapper (name.c_str ());
645 
646  if (status < 0)
647  msg = std::strerror (errno);
648 
649  return status;
650 }
651 
652 // And a version that works recursively.
653 
654 int
655 recursive_rmdir (const std::string& name)
656 {
657  std::string msg;
658  return recursive_rmdir (name, msg);
659 }
660 
661 int
662 recursive_rmdir (const std::string& name, std::string& msg)
663 {
664  msg = "";
665 
666  int status = 0;
667 
668  string_vector dirlist;
669 
670  if (get_dirlist (name, dirlist, msg))
671  {
672  for (octave_idx_type i = 0; i < dirlist.numel (); i++)
673  {
674  octave_quit ();
675 
676  std::string nm = dirlist[i];
677 
678  // Skip current directory and parent.
679  if (nm == "." || nm == "..")
680  continue;
681 
682  std::string fullnm = name + file_ops::dir_sep_str () + nm;
683 
684  // Get info about the file. Don't follow links.
685  file_stat fs (fullnm, false);
686 
687  if (fs)
688  {
689  if (fs.is_dir ())
690  {
691  status = recursive_rmdir (fullnm, msg);
692 
693  if (status < 0)
694  break;
695  }
696  else
697  {
698  status = unlink (fullnm, msg);
699 
700  if (status < 0)
701  break;
702  }
703  }
704  else
705  {
706  msg = fs.error ();
707  break;
708  }
709  }
710 
711  if (status >= 0)
712  status = rmdir (name, msg);
713  }
714  else
715  status = -1;
716 
717  return status;
718 }
719 
720 int
721 umask (mode_t mode)
722 {
723  return octave_umask_wrapper (mode);
724 }
725 
726 int
727 unlink (const std::string& name)
728 {
729  std::string msg;
730  return unlink (name, msg);
731 }
732 
733 int
734 unlink (const std::string& name, std::string& msg)
735 {
736  msg = "";
737 
738  int status = -1;
739 
740  status = octave_unlink_wrapper (name.c_str ());
741 
742  if (status < 0)
743  msg = std::strerror (errno);
744 
745  return status;
746 }
747 
748 std::string
749 tempnam (const std::string& dir, const std::string& pfx)
750 {
751  std::string msg;
752  return tempnam (dir, pfx, msg);
753 }
754 
755 std::string
756 tempnam (const std::string& dir, const std::string& pfx,
757  std::string& msg)
758 {
759  msg = "";
760 
761  std::string retval;
762 
763  // get dir path to use for template
764  std::string templatename;
765  if (dir.empty ())
766  templatename = env::get_temp_directory ();
767  else if (! file_stat (dir, false).is_dir ())
768  templatename = env::get_temp_directory ();
769  else
770  templatename = dir;
771 
772  // add dir sep char if it is not there
773  if (*templatename.rbegin () != file_ops::dir_sep_char ())
774  templatename += file_ops::dir_sep_char ();
775 
776  if (pfx.empty ())
777  templatename += "file";
778  else
779  templatename += pfx;
780 
781  // add the required XXXXXX for the template
782  templatename += "XXXXXX";
783 
784  // create and copy template to char array for call to gen_tempname
785  OCTAVE_LOCAL_BUFFER (char, tname, templatename.length () + 1);
786 
787  strcpy (tname, templatename.c_str ());
788 
789  if (octave_gen_tempname_wrapper (tname) == -1)
790  msg = std::strerror (errno);
791  else
792  retval = tname;
793 
794  return retval;
795 }
796 
797 std::string
798 canonicalize_file_name (const std::string& name)
799 {
800  std::string msg;
801  return canonicalize_file_name (name, msg);
802 }
803 
804 std::string
805 canonicalize_file_name (const std::string& name, std::string& msg)
806 {
807  msg = "";
808 
809  std::string retval;
810 
811  // FIXME: Consider replacing this with std::filesystem::canonical on all
812  // platforms once we allow using C++17.
813 
814 #if defined (OCTAVE_USE_WINDOWS_API)
815  // open file handle
816  std::wstring wname = u8_to_wstring (name);
817  HANDLE h_file = CreateFileW (wname.c_str (), GENERIC_READ,
818  FILE_SHARE_READ, nullptr, OPEN_EXISTING,
819  FILE_FLAG_BACKUP_SEMANTICS, nullptr);
820 
821  // Might have been a symbolic link that points to a network share.
822  // It looks like opening a network share itself (not a file or folder
823  // *on* a share) might return an invalid handle. As a workaround, try to
824  // open a handle to the symbolic link itself (and do not resolve it).
825  if (h_file == INVALID_HANDLE_VALUE)
826  h_file = CreateFileW (wname.c_str (), GENERIC_READ,
827  FILE_SHARE_READ, nullptr, OPEN_EXISTING,
828  FILE_FLAG_BACKUP_SEMANTICS
829  | FILE_FLAG_OPEN_REPARSE_POINT, nullptr);
830 
831  if (h_file == INVALID_HANDLE_VALUE)
832  {
833  msg = "Unable to open file \"" + name + "\"";
834  return retval;
835  }
836 
837  unwind_action close_file_handle (CloseHandle, h_file);
838 
839  const std::size_t buf_size = 32767;
840  wchar_t buffer[buf_size] = L"";
841 
842  // query canonical name
843  DWORD len = GetFinalPathNameByHandleW (h_file, buffer, buf_size,
844  FILE_NAME_NORMALIZED);
845  if (len >= buf_size)
846  {
847  msg = "Error querying normalized name for \"" + name + "\"";
848  return retval;
849  }
850 
851  retval = u8_from_wstring (std::wstring (buffer, len));
852 
853  // remove prefix
854  // "Normal" paths are prefixed by "\\?\".
855  // UNC paths are prefixed by "\\?\UNC\".
856  if (retval.compare (0, 8, R"(\\?\UNC\)") == 0)
857  {
858  retval = retval.erase (2, 6);
859 
860  // If the initial path looked like a mapped network drive, replace
861  // portion of path that corresponds to mapped root with drive root.
862  if (name.size () < 3 || name[1] != ':')
863  return retval;
864 
865  // UNC path corresponding to original drive letter (mappped drive)
866  std::wstring orig_map = wname.substr (0, 3);
867  orig_map[2] = L'\\';
868  HANDLE h_map = CreateFileW (orig_map.c_str (), GENERIC_READ,
869  FILE_SHARE_READ, nullptr, OPEN_EXISTING,
870  FILE_FLAG_BACKUP_SEMANTICS
871  | FILE_FLAG_OPEN_REPARSE_POINT,
872  nullptr);
873 
874  if (h_map == INVALID_HANDLE_VALUE)
875  // cannot determine common root
876  return retval;
877 
878  unwind_action close_map_handle (CloseHandle, h_map);
879  len = GetFinalPathNameByHandleW (h_map, buffer, buf_size,
880  FILE_NAME_NORMALIZED);
881 
882  std::string orig_root
883  = u8_from_wstring (std::wstring (buffer, len));
884 
885  if (orig_root.compare (0, 8, R"(\\?\UNC\)"))
886  // root was not a mapped share
887  return retval;
888 
889  orig_root = orig_root.erase (2, 6);
890  // trim trailing file separators from UNC path corresponding to root
891  std::string file_seps = file_ops::dir_sep_chars ();
892  while (file_seps.find (orig_root.back ()) != std::string::npos)
893  orig_root.pop_back ();
894 
895  if (retval.compare (0, orig_root.size (), orig_root))
896  // start of UNC path doesn't match mapped drive root
897  return retval;
898 
899  // file is on mapped share
900  size_t sep_pos = orig_root.size ();
901  if (sep_pos != retval.size ())
902  retval = retval.substr (sep_pos-2);
903  else
904  retval.resize (2); // no file component
905  retval[0] = std::toupper (name[0]);
906  retval[1] = ':';
907  }
908  else if (retval.compare (0, 4, R"(\\?\)") == 0)
909  retval = retval.erase (0, 4);
910 #else
911  char *tmp = octave_canonicalize_file_name_wrapper (name.c_str ());
912 
913  if (tmp)
914  {
915  retval = tmp;
916  free (tmp);
917  }
918 
919  if (retval.empty ())
920  msg = std::strerror (errno);
921 #endif
922 
923  return retval;
924 }
925 
926 OCTAVE_END_NAMESPACE(sys)
927 OCTAVE_END_NAMESPACE(octave)
char * octave_canonicalize_file_name_wrapper(const char *name)
bool is_dir() const
Definition: file-stat.cc:65
std::string error() const
Definition: file-stat.h:149
static std::string get_temp_directory()
Definition: oct-env.cc:152
bool empty() const
Definition: str-vec.h:77
octave_idx_type numel() const
Definition: str-vec.h:100
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
bool is_dir_sep(char c)
int umask(mode_t)
std::string dir_sep_str()
std::string native_separator_path(const std::string &path)
string_vector tilde_additional_suffixes
std::string dir_sep_chars()
std::string dirname(const std::string &path)
bool is_dev_sep(char c)
tilde_expansion_hook tilde_expansion_failure_hook
char dir_sep_char()
std::string(* tilde_expansion_hook)(const std::string &)
Definition: file-ops.h:43
tilde_expansion_hook tilde_expansion_preexpansion_hook
string_vector tilde_additional_prefixes
char dev_sep_char()
std::string tail(const std::string &path)
int octave_gen_tempname_wrapper(char *tmpl)
std::string u8_from_wstring(const std::wstring &wchar_string)
Definition: lo-sysdep.cc:746
bool file_exists(const std::string &filename, bool is_dir)
Definition: lo-sysdep.cc:341
std::wstring u8_to_wstring(const std::string &utf8_string)
Definition: lo-sysdep.cc:723
bool get_dirlist(const std::string &dirname, string_vector &dirlist, std::string &msg)
Definition: lo-sysdep.cc:120
bool same_file(const std::string &file1, const std::string &file2)
Definition: lo-sysdep.cc:437
octave_idx_type n
Definition: mx-inlines.cc:761
std::string concat(const std::string &dir, const std::string &file)
Definition: file-ops.cc:359
string_vector tilde_expand(const string_vector &names)
Definition: file-ops.cc:346
int symlink(const std::string &old_name, const std::string &new_name, std::string &msg)
Definition: file-ops.cc:538
std::string canonicalize_file_name(const std::string &name, std::string &msg)
Definition: file-ops.cc:805
int readlink(const std::string &path, std::string &result, std::string &msg)
Definition: file-ops.cc:561
int recursive_mkdir(const std::string &name, mode_t mode, std::string &msg)
Definition: file-ops.cc:440
int rename(const std::string &from, const std::string &to, std::string &msg)
Definition: file-ops.cc:589
int rmdir(const std::string &name, std::string &msg)
Definition: file-ops.cc:638
std::string tempnam(const std::string &dir, const std::string &pfx, std::string &msg)
Definition: file-ops.cc:756
int link(const std::string &old_name, const std::string &new_name, std::string &msg)
Definition: file-ops.cc:515
int mkdir(const std::string &name, mode_t mode, std::string &msg)
Definition: file-ops.cc:420
int mkfifo(const std::string &name, mode_t mode, std::string &msg)
Definition: file-ops.cc:495
int recursive_rmdir(const std::string &name, std::string &msg)
Definition: file-ops.cc:662
int unlink(const std::string &name, std::string &msg)
Definition: file-ops.cc:734
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:44
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