]> git.sesse.net Git - nageru/blobdiff - futatabi/main.cpp
Fix a follow-up error introduced when fixing a Coverity Scan issue.
[nageru] / futatabi / main.cpp
index 33a486a56440eb9ca93f62e61a51a3fdc55fa135..edff307e38bd1a98584ef3c0a94d1e176f192538 100644 (file)
@@ -200,13 +200,11 @@ int main(int argc, char **argv)
 
        string frame_dir = global_flags.working_directory + "/frames";
 
-       struct stat st;
-       if (stat(frame_dir.c_str(), &st) == -1) {
+       if (mkdir(frame_dir.c_str(), 0777) == 0) {
                fprintf(stderr, "%s does not exist, creating it.\n", frame_dir.c_str());
-               if (mkdir(frame_dir.c_str(), 0777) == -1) {
-                       perror(global_flags.working_directory.c_str());
-                       exit(1);
-               }
+       } else if (errno != EEXIST) {
+               perror(global_flags.working_directory.c_str());
+               exit(1);
        }
 
        avformat_network_init();
@@ -369,11 +367,12 @@ void load_frame_file(const char *filename, const string &basename, unsigned file
        }
 
        off_t size = ftell(fp);
+       fclose(fp);
+
        if (size == -1) {
                fprintf(stderr, "WARNING: %s: ftell() failed (%s).\n", filename, strerror(errno));
                return;
        }
-       fclose(fp);
 
        db->store_frame_file(basename, size, all_frames);
 }