Mercurial > octave
comparison liboctave/util/cmd-hist.cc @ 32078:632f9b828de1
Avoid using file_stat in liboctave/util (bug #59711).
* cmd-edit.cc (looks_like_filename), cmd-hist.cc (gnu_history::do_append),
kpse.cc (kpse_element_dir), oct-glob.cc (glob, windows_glob),
url-transfer.cc (base_url_transfer::mget_directory): Use functions "dir_exists"
or "file_exists" instead of "file_stat".
* kpse.cc (dir_p), oct-glob.cc (single_match_exists): Remove unused static
functions.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sat, 06 May 2023 10:56:33 +0200 |
parents | 1daf8bfceac3 |
children | ae4e19c0a2b1 2e484f9f1f18 |
comparison
equal
deleted
inserted
replaced
32077:ed3a18fe328a | 32078:632f9b828de1 |
---|---|
369 { | 369 { |
370 // Try to create the folder if it does not exist | 370 // Try to create the folder if it does not exist |
371 std::string hist_dir = sys::file_ops::dirname (f); | 371 std::string hist_dir = sys::file_ops::dirname (f); |
372 if (! hist_dir.empty ()) | 372 if (! hist_dir.empty ()) |
373 { | 373 { |
374 sys::file_stat fs (hist_dir); | 374 if (! sys::dir_exists (hist_dir) |
375 if (! fs.is_dir () | |
376 && (sys::recursive_mkdir (hist_dir, 0777) < 0)) | 375 && (sys::recursive_mkdir (hist_dir, 0777) < 0)) |
377 (*current_liboctave_error_handler) | 376 (*current_liboctave_error_handler) |
378 ("%s: Could not create directory \"%s\" for history", | 377 ("%s: Could not create directory \"%s\" for history", |
379 "gnu_history::do_write", hist_dir.c_str ()); | 378 "gnu_history::do_write", hist_dir.c_str ()); |
380 } | 379 } |
409 if (f.empty ()) | 408 if (f.empty ()) |
410 f = m_file; | 409 f = m_file; |
411 | 410 |
412 if (! f.empty ()) | 411 if (! f.empty ()) |
413 { | 412 { |
414 sys::file_stat fs (f); | 413 if (! sys::file_exists (f)) |
415 | |
416 if (! fs) | |
417 { | 414 { |
418 std::ofstream tmp = sys::ofstream (f, std::ios::out); | 415 std::ofstream tmp = sys::ofstream (f, std::ios::out); |
419 tmp.close (); | 416 tmp.close (); |
420 } | 417 } |
421 | 418 |