]> git.sesse.net Git - nageru/commitdiff
Make search_for_file (in ImageInput) available to the rest of the code.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 12 Apr 2017 16:53:26 +0000 (18:53 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 12 Apr 2017 16:58:36 +0000 (18:58 +0200)
image_input.cpp
image_input.h

index 5c9d7966cd7404b395ddab4ecaf40523c9215549..92c58eca1956bfa595f6d04ba84b0157057b1b8c 100644 (file)
@@ -37,8 +37,6 @@ struct SwsContext;
 
 using namespace std;
 
-namespace {
-
 string search_for_file(const string &filename)
 {
        // Look for the file in all theme_dirs until we find one;
@@ -61,18 +59,25 @@ string search_for_file(const string &filename)
        for (const string &error : errors) {
                fprintf(stderr, "%s\n", error.c_str());
        }
-       fprintf(stderr, "Couldn't find %s in any directory in --theme-dirs, exiting.\n",
-               filename.c_str());
-       exit(1);
+       return "";
 }
 
-}  // namespace
+string search_for_file_or_die(const string &filename)
+{
+       string pathname = search_for_file(filename);
+       if (pathname.empty()) {
+               fprintf(stderr, "Couldn't find %s in any directory in --theme-dirs, exiting.\n",
+                       filename.c_str());
+               exit(1);
+       }
+       return pathname;
+}
 
 ImageInput::ImageInput(const string &filename)
        : movit::FlatInput({movit::COLORSPACE_sRGB, movit::GAMMA_sRGB}, movit::FORMAT_RGBA_POSTMULTIPLIED_ALPHA,
                           GL_UNSIGNED_BYTE, 1280, 720),  // Resolution will be overwritten.
          filename(filename),
-         pathname(search_for_file(filename)),
+         pathname(search_for_file_or_die(filename)),
          current_image(load_image(filename, pathname))
 {
        if (current_image == nullptr) {  // Could happen even though search_for_file() returned.
index 02be497ff40e2dccee5f569a5be2e1e98a6ae4c5..f38426441b0691a73dd6b0cd94f2840a3ff3906c 100644 (file)
@@ -46,4 +46,12 @@ private:
        static std::condition_variable threads_should_quit_modified;  // Signals when threads_should_quit is set.
 };
 
+// Look for the file in all theme_dirs until we find one;
+// that will be the permanent resolution of this file, whether
+// it is actually valid or not. Returns an empty string on error.
+std::string search_for_file(const std::string &filename);
+
+// Same, but exits on error.
+std::string search_for_file_or_die(const std::string &filename);
+
 #endif // !defined(_IMAGE_INPUT_H)