|
wxMaxima
|
Decides whether wxMaxima can open a file it was handed, and how. More...
#include <wx/string.h>Go to the source code of this file.
Enumerations | |
| enum class | wxm::FileOpenKind { WxmWorksheet , WxmxWorksheet , MacFile , XmlWorksheet , Demo , Package , Unsupported } |
| What wxMaxima does with a file it is asked to open. More... | |
Functions | |
| FileOpenKind | wxm::ClassifyFileForOpening (const wxString &file) |
| Which kind of file this is, judged by its name alone. | |
| bool | wxm::FileLooksBinary (const wxString &file) |
| True if the start of the file looks like binary data rather than text. | |
| wxString | wxm::WhyFileCannotBeOpened (const wxString &file) |
| Why wxMaxima won't open this file, or an empty string if it will. | |
| wxString | wxm::MaximaStringLiteral (const wxString &str) |
| A file name as a Maxima string literal, quotes included. | |
Decides whether wxMaxima can open a file it was handed, and how.
A file given on the command line, by the desktop ("Open with") or by the macOS Finder used to be opened whatever it was: every one got a window and a Maxima process of its own, and anything that wasn't a worksheet was sent to Maxima as load("file"). Selecting wxmaxima.exe and its DLLs and opening them with wxMaxima therefore started dozens of windows and Maxima processes at once, each asking its Lisp to load an executable – which GCL, for one, really tries to link in as native code. The machine ran out of memory long before anything useful happened.
Opening a file is now refused unless its type is one wxMaxima knows, and a file whose format is text is refused if it looks binary. Loading a package stays possible for the package types Maxima itself recognises; the "Load package" menu, which the user picks a file for explicitly, is unaffected.
Deliberately GUI-free, so test_FileOpenKind can check it directly.
|
strong |
What wxMaxima does with a file it is asked to open.
| Enumerator | |
|---|---|
| WxmWorksheet | .wxm (and its backup .wxm~): read into the worksheet |
| WxmxWorksheet | .wxmx (and .wxmx~, .zip): read into the worksheet |
| MacFile | .mac or xmaxima's .out: read into the worksheet |
| XmlWorksheet | .xml, the content.xml from a broken .wxmx |
| Demo | .dem: run by Maxima's demo() |
| Package | |
| Unsupported | anything else: refused |
| FileOpenKind wxm::ClassifyFileForOpening | ( | const wxString & | file | ) |
Which kind of file this is, judged by its name alone.
A "#uuid" suffix, by which a cell in a worksheet can be addressed, is ignored.
| bool wxm::FileLooksBinary | ( | const wxString & | file | ) |
True if the start of the file looks like binary data rather than text.
Looks at the first few kilobytes: a NUL byte, or the signature of a Windows, Linux or macOS executable, counts as binary. A file that can't be read counts as not binary; opening it will report that properly.
| wxString wxm::MaximaStringLiteral | ( | const wxString & | str | ) |
A file name as a Maxima string literal, quotes included.
For building commands like load("file"). A file name on Linux and macOS may contain a double quote, which used to end the string early: importing a CSV file named data.csv"),system("... ran a shell command. A backslash is a Maxima escape character too, so an unescaped Windows path lost all of its backslashes.
| wxString wxm::WhyFileCannotBeOpened | ( | const wxString & | file | ) |
Why wxMaxima won't open this file, or an empty string if it will.
Combines ClassifyFileForOpening() with FileLooksBinary() for the kinds that are text. The file has to exist for the content check; whether it exists is not checked here.