comparison libinterp/corefcn/utils.cc @ 32086:3c608abd55f5

Move "same_file" from liboctinterp to liboctave (bug #63803). * libinterp/corefcn/utils.cc, utils.h (same_file): Deprecate function. * libinterp/corefcn/sysdep.cc, sysdep.h (same_file_internal): Remove function. * liboctave/system/lo-sysdep.cc, lo-sysdep.h (same_file): Move function from liboctinterp to liboctave. * libgui/src/m-editor/file-editor.cc (file_editor::find_tab_widget), libinterp/corefcn/fcn-info.cc (file_editor::find_tab_widget), libinterp/corefcn/interpreter.cc (interpreter::execute_startup_files), libinterp/corefcn/load-path.cc (load_path::append): Use function in updated namespace.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 06 May 2023 17:48:27 +0200
parents e9fdfebc6db0
children 05b4479c29d8
comparison
equal deleted inserted replaced
32085:cf03230c0363 32086:3c608abd55f5
292 292
293 // Return TRUE if F and G are both names for the same file. 293 // Return TRUE if F and G are both names for the same file.
294 294
295 bool same_file (const std::string& f, const std::string& g) 295 bool same_file (const std::string& f, const std::string& g)
296 { 296 {
297 return same_file_internal (f, g); 297 return sys::same_file (f, g);
298 } 298 }
299 299
300 DEFUN (is_same_file, args, , 300 DEFUN (is_same_file, args, ,
301 doc: /* -*- texinfo -*- 301 doc: /* -*- texinfo -*-
302 @deftypefn {} {@var{same} =} is_same_file (@var{filepath1}, @var{filepath2}) 302 @deftypefn {} {@var{same} =} is_same_file (@var{filepath1}, @var{filepath2})
335 if (s1_string && s2_string) 335 if (s1_string && s2_string)
336 { 336 {
337 std::string file1 = args(0).string_value (); 337 std::string file1 = args(0).string_value ();
338 std::string file2 = args(1).string_value (); 338 std::string file2 = args(1).string_value ();
339 339
340 retval = same_file (file1, file2); 340 retval = sys::same_file (file1, file2);
341 } 341 }
342 else if ((s1_string && s2_cellstr) || (s1_cellstr && s2_string)) 342 else if ((s1_string && s2_cellstr) || (s1_cellstr && s2_string))
343 { 343 {
344 octave_value str_arg, cellstr_arg; 344 octave_value str_arg, cellstr_arg;
345 345
358 const std::string str = str_arg.string_value (); 358 const std::string str = str_arg.string_value ();
359 359
360 boolNDArray output (cellstr.dims (), false); 360 boolNDArray output (cellstr.dims (), false);
361 361
362 for (octave_idx_type idx = 0; idx < cellstr.numel (); idx++) 362 for (octave_idx_type idx = 0; idx < cellstr.numel (); idx++)
363 output(idx) = same_file (str, cellstr(idx)); 363 output(idx) = sys::same_file (str, cellstr(idx));
364 364
365 retval = output; 365 retval = output;
366 } 366 }
367 else if (s1_cellstr && s2_cellstr) 367 else if (s1_cellstr && s2_cellstr)
368 { 368 {
376 error ("is_same_file: cellstr arrays FILEPATH1 and FILEPATH2 must be the same size"); 376 error ("is_same_file: cellstr arrays FILEPATH1 and FILEPATH2 must be the same size");
377 377
378 boolNDArray output (size1, false); 378 boolNDArray output (size1, false);
379 379
380 for (octave_idx_type idx = 0; idx < cellstr1.numel (); idx++) 380 for (octave_idx_type idx = 0; idx < cellstr1.numel (); idx++)
381 output(idx) = same_file (cellstr1(idx), cellstr2(idx)); 381 output(idx) = sys::same_file (cellstr1(idx), cellstr2(idx));
382 382
383 retval = output; 383 retval = output;
384 } 384 }
385 else 385 else
386 error ("is_same_file: FILEPATH1 and FILEPATH2 must be strings or cell arrays of strings"); 386 error ("is_same_file: FILEPATH1 and FILEPATH2 must be strings or cell arrays of strings");