Add a New Comment (Rich Markup)
Comment Type & Canned Response: None None > Multiple Canned Responses Fixed in development Crash with no stack trace Already fixed in newer version Fixed in stable Bad description Bad description and crash Bad stack trace Obsolete version Duplicate and not fixed Duplicate and needs more info Duplicate and fixed Need info and old
( Jump to the original submission )
I made an equivalent implementation (see attached) with Qt's mimedatabase class and it doesn't look as good as libmagic. Images are well recognized, data files not so well:
fmt = -v7 text/plain fmt = -binary application/octet-stream fmt = -text text/plain fmt = -zip application/gzip fmt = -hdf5 application/x-hdf
Matlab's mat format is seen as plain text, and Octave's binary format is seen as generic binary data. In either case the "comment ()" property doesn't give more hint on the nature of the data.
(file #44309)
I fixed the first issue of non-existent files here:
http://hg.savannah.gnu.org/hgweb/octave/rev/d8aa0e66aa5c
@Mike: according to the SO discussion I mentioned in comment #2, "open" is ran whenever one double clicks a file in the file browser. "open" being a function present in the interpreter, it should work both in CLI and GUI modes. Now what "open" does when it finds e.g. data files (openvar? load? ...) may depend on wether the GUI is running.
Indeed, using Qt's capabilities is probably the way to go (I'd bet it's libmagic in the background anyway). The only disadvantage is the fact that those classes where introduced in Qt 5.0.
If this bug is only relevant for Octave with the GUI active, should we prefer the Qt desktop integration MIME functions to yet another additional third-party library?
https://doc.qt.io/qt-5/qmimedatabase.html
That's why I asked if this problem is only relevant for when the GUI is active.
If someone uses the open function in command-line mode, shouldn't it always open the file in an external program unconditionally?
If the GUI is active, then the interpreter can defer to the GUI to determine how the file should be opened.
I attached a very simple wrapper around libmagic, that I tested as follows:
im = rand (10,10,3); fname = "toto.titi"; ## Images fmts = {"png", "tiff", "gif", "jpeg"}; for ii = 1:numel (fmts) fmt = fmts{ii} imwrite (im, fname, fmt); disp (fileinfo (fname)) disp ("") endfor ## Octave generated data fmts = {"-v7", "-binary", "-text", "-zip", "-hdf5"}; for ii = 1:numel (fmts) fmt = fmts{ii} save (fmt, fname, "im"); disp (fileinfo (fname)) disp ("") endfor
and here is the result
fmt = png PNG image data, 10 x 10, 8-bit/color RGB, non-interlaced fmt = tiff TIFF image data, little-endian fmt = gif GIF image data, version 89a, 10 x 10 fmt = jpeg JPEG image data, JFIF standard 1.01 fmt = -v7 Matlab v5 mat-file (little endian) version 0x0100 fmt = -binary Octave binary data (little endian) fmt = -text ASCII text fmt = -zip gzip compressed data, from Unix fmt = -hdf5 Hierarchical Data Format (version 5) data
If you want to test, you need to install the developper version of libmagic and compile fileinfo.cc as follows
mkoctfile -lmagic ./fileinfo.cc
(file #44307)
@gyom: Testing if the file exists is reasonable (and easy).
For binary and text data handling I think it is necessary to have some mime type checking layer (maybe using libmagic, like the file command) if we want to do sensible choices when it comes to handling contents (image? numeric tables? hdf5 files ? ...). Matlab seams to have "finfo" to do that job, but I couldn't find documentation on the web ("help finfo" works in Matlab though). See e.g :
https://stackoverflow.com/questions/22067730/matlab-open-files-outside-matlab-by-default
The above is not a short project, so at least we should be able to determine if a suitable fall-back application has been found on the system, and fire a warning otherwise.
If random.dat happens to be a zip file does Matlab open it in WinZip or whatever program is installed to handle zip files? Does it matter if it is named random.dat or random.zip?
In what format does Matlab read random data to open it in the variable editor, as a uint8 array?
What is the behavior if Matlab is started in non GUI mode?
This is a follow-up of bug #50543 (comments 7 to 11).
Given a binary file, a text file and a non-existing file:
dd if=/dev/urandom of=random.dat count=100 # file: data echo blah blah blah > random.text # file: ASCII text
Matlab's behavior is:
>> open nonexisting.file Error using open (line 86) File 'nonexisting.file' not found. >> open random.dat % try to display data in the variable editor >> open random.text % open file in Matlab's text editor
while Octave does nothing for a binary or non-existing file and opens the text file in the system's text editor (not Octave's).
(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)
Attach Files: Comment:
Depends on the following items: None found
Items that depend on this one: None found
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 project members can vote.
Please enter the title of George Orwell's famous dystopian book (it's a date):
Follow 4 latest changes.
Copyright © 2023 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. The Levitating, Meditating, Flute-playing Gnu logo is a GNU GPL'ed image provided by the Nevrax Design Team. Source Code
Powered by Savane 3.10