diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2017-05-13 19:06:24 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2017-05-13 19:06:24 +0000 |
| commit | d6170f0d771ce86df57dc90c9c9ac4d6f8845c7d (patch) | |
| tree | ec05764f96fed5b089890de5c1c1328d51b9c909 /src/inkview.cpp | |
| parent | Inkview: Print error in correct encoding. (diff) | |
| download | inkscape-d6170f0d771ce86df57dc90c9c9ac4d6f8845c7d.tar.gz inkscape-d6170f0d771ce86df57dc90c9c9ac4d6f8845c7d.zip | |
Inkview: Put checking for valid files in separate function
(bzr r15690.1.3)
Diffstat (limited to 'src/inkview.cpp')
| -rw-r--r-- | src/inkview.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/inkview.cpp b/src/inkview.cpp index 3cca34d6c..0358fe917 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -244,6 +244,29 @@ private: }; +/** get a list of valid SVG files from a list of strings */ +std::vector<Glib::ustring> get_valid_files(std::vector<Glib::ustring> filenames) +{ + std::vector<Glib::ustring> valid_files; + + for(auto file : filenames) + { + if (!Inkscape::IO::file_test( file.c_str(), G_FILE_TEST_EXISTS )) { + g_printerr("File does not exist: %s\n", file.c_str()); + } else { + auto doc = SPDocument::createNewDoc(file.c_str(), TRUE, false); + + if(doc) + { + /* Append to list */ + valid_files.push_back(file); + } + } + } + + return valid_files; +} + #ifdef WIN32 // minimal print handler (just prints the string to stdout) void g_print_no_convert(const gchar *buf) { fputs(buf, stdout); } @@ -285,23 +308,7 @@ int main (int argc, char **argv) exit(EXIT_FAILURE); } - std::vector<Glib::ustring> valid_files; - - for(auto file : filenames) - { - if (!Inkscape::IO::file_test( file.c_str(), G_FILE_TEST_EXISTS )) { - g_printerr("File does not exist: %s\n", file.c_str()); - } else { - auto doc = SPDocument::createNewDoc(file.c_str(), TRUE, false); - - if(doc) - { - /* Append to list */ - valid_files.push_back(file); - } - } - } - + std::vector<Glib::ustring> valid_files = get_valid_files(filenames); if(valid_files.empty()) { return 1; /* none of the slides loadable */ } |
