bugGNU Octave - Bugs: bug #54508, isfile function needed for Matlab...

 
 

bug #54508: isfile function needed for Matlab compatibility

Submitter:  Rik <rik5>
Submitted:  Mon 13 Aug 2018 07:23:38 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  rik5
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 13 Aug 2018 09:45:34 PM UTC, comment #3: 

I added the new function isfile here https://hg.savannah.gnu.org/hgweb/octave/rev/0862570da0ae.

It might be worth replacing these instances of exist with isfile or isfolder that I found through grepping.


help/doc.m:81:          && ! exist ([info_file_name ".bz2"], "file"))
help/doc.m:116:%! if (exist (ifile) != 2 && exist (sprintf ("%s.gz", ifile)) != 2)
miscellaneous/copyfile.m:144:%!   assert (exist (f2, "file"));
miscellaneous/grabcode.m:59:  if (exist (url) == 2)
/bin/grep: miscellaneous/isdir.m: No such file or directory
miscellaneous/movefile.m:157:%!   assert (exist (f2, "file"));
miscellaneous/open.m:77:      && any (exist (["open" tolower(ext(2:end))]) == [2 3 5 103]))
miscellaneous/publish.m:199:  if (exist (file, "file") != 2)
miscellaneous/publish.m:208:  if (exist ([file_name, file_ext]) != 2)
path/private/getsavepath.m:27:  if (exist (file) == 2)
pkg/private/install.m:507:          if (! exist (octm2, "dir"))
plot/util/print.m:334:  do_unlink = (exist (opts.name, "file") != 2);


But for now, I'm going to close this report as fixed.


Rik <rik5>
Group administrator
Mon 13 Aug 2018 08:24:26 PM UTC, comment #2: 

Great.  I'll get around to creating isfile.m soon.

Rik <rik5>
Group administrator
Mon 13 Aug 2018 07:41:40 PM UTC, comment #1: 

I think the code you have is exactly correct. I asked someone to do some basic testing, and isfile does return false on devices, sockets, and fifos.

Note that 'stat' dereferences symbolic links, so it is correct that 'stat' on a symbolic link that points to an actual existing file will correctly indicate that it is a file, not a symbolic link. The Matlab 'isfile' function behaves the same, returns true if given a symbolic link that points to an ordinary file. That conforms with the usual user interface for symbolic links, treat them exactly as the thing they point to.

Mike Miller <mtmiller>
Group Member
Mon 13 Aug 2018 07:23:38 PM UTC, original submission:  

Octave has an isfolder.m function to test whether a name is a directory.  Matlab has a similar function isfile() to test whether a name is a file.

It would be very simple to implement an isfile.m function in Octave based on isfolder.  The only question is how non-text files are handled.  For example, is a symbolic link still a "file" according to Matlab's implementation of isfile()?

We need someone to check isfile() on Linux on files which are symbolic links, FIFOs, and sockets.  If those all return false then the code for isfile is just


[info, err] = stat (f{i});
retval(i) = (! err && S_ISREG (info.mode));



Rik <rik5>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-13 rik5 StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2018-08-13 rik5 StatusConfirmed In Progress
        Assigned toNone rik5

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code