GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
lo-sysdep.cc
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 (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <cstdlib>
31#include <locale>
32#include <codecvt>
33
34#include "dir-ops.h"
35#include "file-ops.h"
36#include "lo-error.h"
37#include "lo-sysdep.h"
39#include "putenv-wrapper.h"
40#include "unistd-wrappers.h"
41#include "unsetenv-wrapper.h"
42
43#if defined (OCTAVE_USE_WINDOWS_API)
44# include <windows.h>
45# include <wchar.h>
46
47# include "filepos-wrappers.h"
48# include "lo-hash.h"
49# include "oct-locbuf.h"
50# include "uniconv-wrappers.h"
51# include "unwind-prot.h"
52#endif
53
54namespace octave
55{
56 namespace sys
57 {
58 int
59 system (const std::string& cmd_str)
60 {
61#if defined (OCTAVE_USE_WINDOWS_API)
62 const std::wstring wcmd_str = u8_to_wstring (cmd_str);
63
64 return _wsystem (wcmd_str.c_str ());
65#else
66 return ::system (cmd_str.c_str ());
67#endif
68 }
69
70 std::string
71 getcwd (void)
72 {
73 std::string retval;
74
75#if defined (OCTAVE_USE_WINDOWS_API)
76 wchar_t *tmp = _wgetcwd (nullptr, 0);
77
78 if (! tmp)
79 (*current_liboctave_error_handler) ("unable to find current directory");
80
81 std::wstring tmp_wstr (tmp);
82 free (tmp);
83
84 std::string tmp_str = u8_from_wstring (tmp_wstr);
85
86 retval = tmp_str;
87
88#else
89 // Using octave_getcwd_wrapper ensures that we have a getcwd that
90 // will allocate a buffer as large as necessary if buf and size are
91 // both 0.
92
93 char *tmp = octave_getcwd_wrapper (nullptr, 0);
94
95 if (! tmp)
96 (*current_liboctave_error_handler) ("unable to find current directory");
97
98 retval = tmp;
99 free (tmp);
100#endif
101
102 return retval;
103 }
104
105 int
106 chdir (const std::string& path_arg)
107 {
108 std::string path = sys::file_ops::tilde_expand (path_arg);
109
110#if defined (OCTAVE_USE_WINDOWS_API)
111 if (path.length () == 2 && path[1] == ':')
112 path += '\\';
113#endif
114
115 return octave_chdir_wrapper (path.c_str ());
116 }
117
118 bool
119 get_dirlist (const std::string& dirname, string_vector& dirlist,
120 std::string& msg)
121 {
122 dirlist = "";
123 msg = "";
124#if defined (OCTAVE_USE_WINDOWS_API)
125 _WIN32_FIND_DATAW ffd;
126
127 std::string path_name (dirname);
128 if (path_name.empty ())
129 return true;
130
131 if (path_name.back () == '\\' || path_name.back () == '/')
132 path_name.push_back ('*');
133 else
134 path_name.append (R"(\*)");
135
136 // Find first file in directory.
137 std::wstring wpath_name = u8_to_wstring (path_name);
138 HANDLE hFind = FindFirstFileW (wpath_name.c_str (), &ffd);
139 if (INVALID_HANDLE_VALUE == hFind)
140 {
141 DWORD errCode = GetLastError ();
142 char *errorText = nullptr;
143 FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM |
144 FORMAT_MESSAGE_ALLOCATE_BUFFER |
145 FORMAT_MESSAGE_IGNORE_INSERTS,
146 nullptr, errCode,
147 MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
148 reinterpret_cast <char *> (&errorText), 0, nullptr);
149 if (errorText != nullptr)
150 {
151 msg = std::string (errorText);
152 LocalFree (errorText);
153 }
154 return false;
155 }
156
157 std::list<std::string> dirlist_str;
158 do
159 dirlist_str.push_back (u8_from_wstring (ffd.cFileName));
160 while (FindNextFileW (hFind, &ffd) != 0);
161
162 FindClose(hFind);
163
164 dirlist = string_vector (dirlist_str);
165
166#else
167
168 dir_entry dir (dirname);
169
170 if (! dir)
171 {
172 msg = dir.error ();
173 return false;
174 }
175
176 dirlist = dir.read ();
177
178 dir.close ();
179#endif
180
181 return true;
182 }
183
184#if defined (OCTAVE_USE_WINDOWS_API)
185
186 static bool check_fseek_ftell_workaround_needed (bool set_nonbuffered_mode)
187 {
188 // To check whether the workaround is needed:
189 //
190 // * Create a tmp file with LF line endings only.
191 //
192 // * Open that file for reading in text mode.
193 //
194 // * Read a line.
195 //
196 // * Use ftello to record the position of the beginning of the
197 // second line.
198 //
199 // * Read and save the contents of the second line.
200 //
201 // * Use fseeko to return to the saved position.
202 //
203 // * Read the second line again and compare to the previously
204 // saved text.
205 //
206 // * If the lines are different, we need to set non-buffered
207 // input mode for files opened in text mode.
208
209 std::string tmpname = sys::tempnam ("", "oct-");
210
211 if (tmpname.empty ())
212 {
213 (*current_liboctave_warning_handler)
214 ("fseek/ftell bug check failed (tmp name creation)!");
215 return false;
216 }
217
218 std::FILE *fptr = std::fopen (tmpname.c_str (), "wb");
219
220 if (! fptr)
221 {
222 (*current_liboctave_warning_handler)
223 ("fseek/ftell bug check failed (opening tmp file for writing)!");
224 return false;
225 }
226
227 fprintf (fptr, "%s", "foo\nbar\nbaz\n");
228
229 std::fclose (fptr);
230
231 fptr = std::fopen (tmpname.c_str (), "rt");
232
233 if (! fptr)
234 {
235 (*current_liboctave_warning_handler)
236 ("fseek/ftell bug check failed (opening tmp file for reading)!");
237 return false;
238 }
239
240 unwind_action act ([=] ()
241 {
242 std::fclose (fptr);
243 sys::unlink (tmpname);
244 });
245
246 if (set_nonbuffered_mode)
247 ::setvbuf (fptr, nullptr, _IONBF, 0);
248
249 while (true)
250 {
251 int c = fgetc (fptr);
252
253 if (c == EOF)
254 {
255 (*current_liboctave_warning_handler)
256 ("fseek/ftell bug check failed (skipping first line)!");
257 return false;
258 }
259
260 if (c == '\n')
261 break;
262 }
263
264 off_t pos = octave_ftello_wrapper (fptr);
265
266 char buf1[8];
267 int i = 0;
268 while (true)
269 {
270 int c = fgetc (fptr);
271
272 if (c == EOF)
273 {
274 (*current_liboctave_warning_handler)
275 ("fseek/ftell bug check failed (reading second line)!");
276 return false;
277 }
278
279 if (c == '\n')
280 break;
281
282 buf1[i++] = static_cast<char> (c);
283 }
284 buf1[i] = '\0';
285
287
288 char buf2[8];
289 i = 0;
290 while (true)
291 {
292 int c = fgetc (fptr);
293
294 if (c == EOF)
295 {
296 (*current_liboctave_warning_handler)
297 ("fseek/ftell bug check failed (reading after repositioning)!");
298 return false;
299 }
300
301 if (c == '\n')
302 break;
303
304 buf2[i++] = static_cast<char> (c);
305 }
306 buf2[i] = '\0';
307
308 return strcmp (buf1, buf2);
309 }
310
311#endif
312
313 std::FILE *
314 fopen (const std::string& filename, const std::string& mode)
315 {
316#if defined (OCTAVE_USE_WINDOWS_API)
317
318 std::wstring wfilename = u8_to_wstring (filename);
319 std::wstring wmode = u8_to_wstring (mode);
320
321 std::FILE *fptr = _wfopen (wfilename.c_str (), wmode.c_str ());
322
323 static bool fseek_ftell_bug_workaround_needed = false;
324 static bool fseek_ftell_bug_checked = false;
325
326 if (! fseek_ftell_bug_checked && mode.find ('t') != std::string::npos)
327 {
328 // FIXME: Is the following workaround needed for all files
329 // opened in text mode, or only for files opened for reading?
330
331 // Try to avoid fseek/ftell bug on Windows systems by setting
332 // non-buffered input mode for files opened in text mode, but
333 // only if it appears that the workaround is needed. See
334 // Octave bug #58055.
335
336 // To check whether the workaround is needed:
337 //
338 // * Create a tmp file with LF line endings only.
339 //
340 // * Open that file for reading in text mode.
341 //
342 // * Read a line.
343 //
344 // * Use ftello to record the position of the beginning of
345 // the second line.
346 //
347 // * Read and save the contents of the second line.
348 //
349 // * Use fseeko to return to the saved position.
350 //
351 // * Read the second line again and compare to the
352 // previously saved text.
353 //
354 // * If the lines are different, we need to set non-buffered
355 // input mode for files opened in text mode.
356 //
357 // * To verify that the workaround solves the problem,
358 // repeat the above test with non-buffered input mode. If
359 // that fails, warn that there may be trouble with
360 // ftell/fseek when reading files opened in text mode.
361
362 if (check_fseek_ftell_workaround_needed (false))
363 {
364 if (check_fseek_ftell_workaround_needed (true))
365 (*current_liboctave_warning_handler)
366 ("fseek/ftell may fail for files opened in text mode");
367 else
368 fseek_ftell_bug_workaround_needed = true;
369 }
370
371 fseek_ftell_bug_checked = true;
372 }
373
374 if (fseek_ftell_bug_workaround_needed
375 && mode.find ('t') != std::string::npos)
376 ::setvbuf (fptr, nullptr, _IONBF, 0);
377
378 return fptr;
379
380#else
381 return std::fopen (filename.c_str (), mode.c_str ());
382#endif
383 }
384
386 fstream (const std::string& filename, const std::ios::openmode mode)
387 {
388#if defined (OCTAVE_USE_WINDOWS_API)
389
390 std::wstring wfilename = u8_to_wstring (filename);
391
392 return std::fstream (wfilename.c_str (), mode);
393
394#else
395 return std::fstream (filename.c_str (), mode);
396#endif
397 }
398
400 ifstream (const std::string& filename, const std::ios::openmode mode)
401 {
402#if defined (OCTAVE_USE_WINDOWS_API)
403
404 std::wstring wfilename = u8_to_wstring (filename);
405
406 return std::ifstream (wfilename.c_str (), mode);
407
408#else
409 return std::ifstream (filename.c_str (), mode);
410#endif
411 }
412
414 ofstream (const std::string& filename, const std::ios::openmode mode)
415 {
416#if defined (OCTAVE_USE_WINDOWS_API)
417
418 std::wstring wfilename = u8_to_wstring (filename);
419
420 return std::ofstream (wfilename.c_str (), mode);
421
422#else
423 return std::ofstream (filename.c_str (), mode);
424#endif
425 }
426
427 void
428 putenv_wrapper (const std::string& name, const std::string& value)
429 {
430 std::string new_env = name + "=" + value;
431
432 // FIXME: The malloc leaks memory, but so would a call to setenv.
433 // Short of extreme measures to track memory, altering the environment
434 // always leaks memory, but the saving grace is that the leaks are small.
435
436 // As far as I can see there's no way to distinguish between the
437 // various errors; putenv doesn't have errno values.
438
439#if defined (OCTAVE_USE_WINDOWS_API)
440 std::wstring new_wenv = u8_to_wstring (new_env);
441
442 int len = (new_wenv.length () + 1) * sizeof (wchar_t);
443
444 wchar_t *new_item = static_cast<wchar_t *> (std::malloc (len));
445
446 wcscpy (new_item, new_wenv.c_str());
447
448 if (_wputenv (new_item) < 0)
449 (*current_liboctave_error_handler)
450 ("putenv (%s) failed", new_env.c_str());
451#else
452 int len = new_env.length () + 1;
453
454 char *new_item = static_cast<char *> (std::malloc (len));
455
456 std::strcpy (new_item, new_env.c_str());
457
458 if (octave_putenv_wrapper (new_item) < 0)
459 (*current_liboctave_error_handler) ("putenv (%s) failed", new_item);
460#endif
461 }
462
463 std::string
464 getenv_wrapper (const std::string& name)
465 {
466#if defined (OCTAVE_USE_WINDOWS_API)
467 std::wstring wname = u8_to_wstring (name);
468 wchar_t *env = _wgetenv (wname.c_str ());
469 return env ? u8_from_wstring (env) : "";
470#else
471 char *env = ::getenv (name.c_str ());
472 return env ? env : "";
473#endif
474 }
475
476 int
477 unsetenv_wrapper (const std::string& name)
478 {
479#if defined (OCTAVE_USE_WINDOWS_API)
480 putenv_wrapper (name, "");
481
482 std::wstring wname = u8_to_wstring (name);
483 return (SetEnvironmentVariableW (wname.c_str (), nullptr) ? 0 : -1);
484#else
485 return octave_unsetenv_wrapper (name.c_str ());
486#endif
487 }
488
489 std::wstring
490 u8_to_wstring (const std::string& utf8_string)
491 {
492 // convert multibyte UTF-8 string to wide character string
493 static std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t>
494 wchar_conv;
495
496 std::wstring retval = L"";
497
498 try
499 {
500 retval = wchar_conv.from_bytes (utf8_string);
501 }
502 catch (const std::range_error& e)
503 {
504 // What to do in case of error?
505 // error ("u8_to_wstring: converting from UTF-8 to wchar_t: %s",
506 // e.what ());
507 }
508
509 return retval;
510 }
511
512 std::string
513 u8_from_wstring (const std::wstring& wchar_string)
514 {
515 // convert wide character string to multibyte UTF-8 string
516 static std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t>
517 wchar_conv;
518
519 std::string retval = "";
520
521 try
522 {
523 retval = wchar_conv.to_bytes (wchar_string);
524 }
525 catch (const std::range_error& e)
526 {
527 // What to do in case of error?
528 // error ("u8_from_wstring: converting from wchar_t to UTF-8: %s",
529 // e.what ());
530 }
531
532 return retval;
533 }
534
535 // At quite a few places in the code we are passing file names as
536 // char arrays to external library functions.
537
538 // When these functions try to locate the corresponding file on the
539 // disc, they need to use the wide character API on Windows to
540 // correctly open files with non-ASCII characters.
541
542 // But they have no way of knowing which encoding we are using for
543 // the passed string. So they have no way of reliably converting to
544 // a wchar_t array. (I.e. there is no possible fix for these
545 // functions with current C or C++.)
546
547 // To solve the dilemma, the function "get_ASCII_filename" first
548 // checks whether there are any non-ASCII characters in the passed
549 // file name. If there are not, it returns the original name.
550
551 // Otherwise, it optionally tries to convert the file name to the locale
552 // charset.
553
554 // If the file name contains characters that cannot be converted to the
555 // locale charset (or that step is skipped), it tries to obtain the short
556 // file name (8.3 naming scheme) which only consists of ASCII characters
557 // and are safe to pass. However, short file names can be disabled for
558 // performance reasons on the file system level with NTFS and they are not
559 // stored on other file systems (e.g. ExFAT). So there is no guarantee
560 // that these exist.
561
562 // If short file names are not stored, a hard link to the file is
563 // created. For this the path to the file is split at the deepest
564 // possible level that doesn't contain non-ASCII characters. At
565 // that level a hidden folder is created that holds the hard links.
566 // That means we need to have write access on that location. A path
567 // to that hard link is returned.
568
569 // If the file system is FAT32, there are no hard links. But FAT32
570 // always stores short file names. So we are safe.
571
572 // ExFAT that is occasionally used on USB sticks and SD cards stores
573 // neither short file names nor does it support hard links. So for
574 // exFAT with this function, there is (currently) no way to generate
575 // a file name that is stripped from non-ASCII characters but still
576 // is valid.
577
578 // For Unixy systems, this function does nothing.
579
580 std::string
581 get_ASCII_filename (const std::string& orig_file_name,
582 const bool allow_locale)
583 {
584#if defined (OCTAVE_USE_WINDOWS_API)
585
586 // Return file name that only contains ASCII characters that can
587 // be used to access the file orig_file_name. The original file
588 // must exist in the file system before calling this function.
589 // This is useful for passing file names to functions that are not
590 // aware of the character encoding we are using.
591
592 // 0. Check whether filename contains non-ASCII (UTF-8) characters.
593
594 std::string::const_iterator first_non_ASCII
595 = std::find_if (orig_file_name.begin (), orig_file_name.end (),
596 [](char c) { return (c < 0 || c >= 128); });
597
598 if (first_non_ASCII == orig_file_name.end ())
599 return orig_file_name;
600
601 // 1. Optionally, check if all characters in the path can be successfully
602 // converted to the locale charset
603 if (allow_locale)
604 {
605 const char *locale = octave_locale_charset_wrapper ();
606 if (locale)
607 {
608 const uint8_t *name_u8 = reinterpret_cast<const uint8_t *>
609 (orig_file_name.c_str ());
610 std::size_t length = 0;
611 char *name_locale = octave_u8_conv_to_encoding_strict
612 (locale, name_u8,
613 orig_file_name.length () + 1, &length);
614 if (name_locale)
615 {
616 std::string file_name_locale (name_locale, length);
617 free (name_locale);
618 return file_name_locale;
619 }
620 }
621 }
622
623 // 2. Check if file system stores short filenames (might be ASCII-only).
624
625 std::wstring w_orig_file_name_str = u8_to_wstring (orig_file_name);
626 const wchar_t *w_orig_file_name = w_orig_file_name_str.c_str ();
627
628 // Get full path to file
629 wchar_t w_full_file_name[_MAX_PATH];
630 if (_wfullpath (w_full_file_name, w_orig_file_name, _MAX_PATH) == nullptr)
631 return orig_file_name;
632
633 std::wstring w_full_file_name_str = w_full_file_name;
634
635 // Get short filename (8.3) from UTF-16 filename.
636
637 long length = GetShortPathNameW (w_full_file_name, nullptr, 0);
638
639 if (length > 0)
640 {
641 // Dynamically allocate the correct size (terminating null char
642 // was included in length).
643
644 OCTAVE_LOCAL_BUFFER (wchar_t, w_short_file_name, length);
645 GetShortPathNameW (w_full_file_name, w_short_file_name, length);
646
647 std::wstring w_short_file_name_str
648 = std::wstring (w_short_file_name, length);
649
650 if (w_short_file_name_str.compare (0, length-1, w_full_file_name_str) != 0)
651 {
652 // Check whether short file name contains non-ASCII characters
653 std::string short_file_name
654 = u8_from_wstring (w_short_file_name_str);
655 first_non_ASCII
656 = std::find_if (short_file_name.begin (),
657 short_file_name.end (),
658 [](char c) { return (c < 0 || c >= 128); });
659 if (first_non_ASCII == short_file_name.end ())
660 return short_file_name;
661 }
662 }
663
664 // 3. Create hard link with only-ASCII characters.
665 // Get longest possible part of path that only contains ASCII chars.
666
667 std::wstring::iterator w_first_non_ASCII
668 = std::find_if (w_full_file_name_str.begin (), w_full_file_name_str.end (),
669 [](wchar_t c) { return (c < 0 || c >= 128); });
670 std::wstring tmp_substr
671 = std::wstring (w_full_file_name_str.begin (), w_first_non_ASCII);
672
673 std::size_t pos
674 = tmp_substr.find_last_of (u8_to_wstring (file_ops::dir_sep_chars ()));
675
676 std::string par_dir
677 = u8_from_wstring (w_full_file_name_str.substr (0, pos+1));
678
679 // Create .oct_ascii directory.
680 // FIXME: We need to have write permission in this location.
681
682 std::string oct_ascii_dir = par_dir + ".oct_ascii";
683 std::string test_dir = canonicalize_file_name (oct_ascii_dir);
684
685 if (test_dir.empty ())
686 {
687 std::string msg;
688 int status = sys::mkdir (oct_ascii_dir, 0777, msg);
689
690 if (status < 0)
691 return orig_file_name;
692
693 // Set hidden property.
694 SetFileAttributesA (oct_ascii_dir.c_str (), FILE_ATTRIBUTE_HIDDEN);
695 }
696
697 // Create file from hash of full filename.
698 std::string filename_hash
699 = (oct_ascii_dir + file_ops::dir_sep_str ()
700 + crypto::hash ("SHA1", orig_file_name));
701
702 std::string abs_filename_hash = canonicalize_file_name (filename_hash);
703
704 if (! abs_filename_hash.empty ())
705 sys::unlink (filename_hash);
706
707 wchar_t w_filename_hash[filename_hash.length ()+1] = {0};
708
709 for (std::size_t i=0; i < filename_hash.length (); i++)
710 w_filename_hash[i] = filename_hash.at (i);
711
712 if (CreateHardLinkW (w_filename_hash, w_orig_file_name, nullptr))
713 return filename_hash;
714
715#else
716
717 octave_unused_parameter (allow_locale);
718
719#endif
720
721 return orig_file_name;
722 }
723 }
724}
#define SEEK_SET
Definition: dir-ops.h:42
bool close(void)
Definition: dir-ops.cc:93
string_vector read(void)
Definition: dir-ops.cc:73
std::string error(void) const
Definition: dir-ops.h:88
int octave_fseeko_wrapper(FILE *fp, off_t offset, int whence)
off_t octave_ftello_wrapper(FILE *fp)
QString path
QString name
const char * octave_locale_charset_wrapper(void)
std::string hash(hash_fptr hash_fcn, const std::string &str, int result_buf_len)
Definition: lo-hash.cc:45
FloatComplex(* fptr)(const FloatComplex &, float, int, octave_idx_type &)
Definition: lo-specfun.cc:1128
OCTAVE_API bool strcmp(const T &str_a, const T &str_b)
True if strings are the same.
std::string dirname(const std::string &path)
Definition: file-ops.cc:358
std::string tilde_expand(const std::string &name)
Definition: file-ops.cc:281
std::string dir_sep_chars(void)
Definition: file-ops.cc:247
std::string dir_sep_str(void)
Definition: file-ops.cc:238
std::string getcwd(void)
Definition: lo-sysdep.cc:71
std::fstream fstream(const std::string &filename, const std::ios::openmode mode)
Definition: lo-sysdep.cc:386
std::string tempnam(const std::string &dir, const std::string &pfx)
Definition: file-ops.cc:641
std::ifstream ifstream(const std::string &filename, const std::ios::openmode mode)
Definition: lo-sysdep.cc:400
std::string canonicalize_file_name(const std::string &name)
Definition: file-ops.cc:688
std::string u8_from_wstring(const std::wstring &wchar_string)
Definition: lo-sysdep.cc:513
int unsetenv_wrapper(const std::string &name)
Definition: lo-sysdep.cc:477
std::ofstream ofstream(const std::string &filename, const std::ios::openmode mode)
Definition: lo-sysdep.cc:414
int mkdir(const std::string &nm, mode_t md)
Definition: file-ops.cc:399
std::wstring u8_to_wstring(const std::string &utf8_string)
Definition: lo-sysdep.cc:490
std::string getenv_wrapper(const std::string &name)
Definition: lo-sysdep.cc:464
std::string get_ASCII_filename(const std::string &orig_file_name, const bool allow_locale)
Definition: lo-sysdep.cc:581
int unlink(const std::string &name)
Definition: file-ops.cc:621
void putenv_wrapper(const std::string &name, const std::string &value)
Definition: lo-sysdep.cc:428
bool get_dirlist(const std::string &dirname, string_vector &dirlist, std::string &msg)
Definition: lo-sysdep.cc:119
std::FILE * fopen(const std::string &filename, const std::string &mode)
Definition: lo-sysdep.cc:314
int system(const std::string &cmd_str)
Definition: lo-sysdep.cc:59
int chdir(const std::string &path_arg)
Definition: lo-sysdep.cc:106
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:44
void * malloc(unsigned)
void free(void *)
int octave_putenv_wrapper(char *str)
char * octave_u8_conv_to_encoding_strict(const char *tocode, const uint8_t *src, size_t srclen, size_t *lengthp)
char * octave_getcwd_wrapper(char *nm, size_t len)
int octave_chdir_wrapper(const char *nm)
int octave_unsetenv_wrapper(const char *name)
F77_RET_T len
Definition: xerbla.cc:61