|
wxMaxima
|
Decides whether wxMaxima can open a file it was handed, and how. More...
#include "FileOpenKind.h"#include <wx/file.h>#include <wx/intl.h>#include <wx/log.h>#include <algorithm>#include <array>#include <cstring>#include <string_view>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.
| 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.