search fixes, preset fixes, ladspa icon logging, igor pref theme, drag btn rollover
[goodguy/history.git] / cinelerra-5.1 / cinelerra / filelist.C
index e910e8e8ad057c599c51aecc921690d8bc01c246..4614f3f831f40cf9e842f3be3dafd65b629448c5 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <ctype.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
@@ -76,22 +77,27 @@ int FileList::reset_parameters_derived()
 
 int FileList::open_file(int rd, int wr)
 {
-       int result = 0;
+       int result = 1;
 
 // skip header for write
        if(file->wr)
        {
+               int fd = open(asset->path, O_CREAT+O_TRUNC+O_RDWR, 0777);
+               if( fd >= 0 ) {
+                       close(fd);
+                       result = 0;
 // Frame files are created in write_frame and list index is created when
 // file is closed.
 // Look for the starting number in the path but ignore the starting character
 // and total digits since these are used by the header.
-               Render::get_starting_number(asset->path,
-                       first_number,
-                       number_start,
-                       number_digits);
-               path_list.remove_all_objects();
-               writer = new FrameWriter(this,
+                       Render::get_starting_number(asset->path,
+                               first_number, number_start, number_digits);
+                       path_list.remove_all_objects();
+                       writer = new FrameWriter(this,
                        asset->format == list_type ? file->cpus : 1);
+               }
+               else
+                       eprintf(_("Error while opening \"%s\" for writing. \n%m\n"), asset->path);
        }
        else
        if(file->rd)
@@ -132,15 +138,16 @@ int FileList::open_file(int rd, int wr)
                                                asset->frame_rate = 1;
                                        asset->video_length = -1;
                                }
+                               result = 0;
                        }
+                       else
+                               eprintf(_("Error while opening \"%s\" for reading. \n%m\n"), asset->path);
                }
                else
                {
                        Render::get_starting_number(asset->path,
-                               first_number,
-                               number_start,
-                               number_digits,
-                               6);
+                               first_number, number_start, number_digits, 6);
+                       result = 0;
                }
        }
 
@@ -172,6 +179,7 @@ int FileList::close_file()
 int FileList::write_list_header()
 {
        FILE *stream = fopen(asset->path, "w");
+       if( !stream ) return 1;
 // Use sprintf instead of fprintf for VFS.
        char string[BCTEXTLEN];
        sprintf(string, "%s\n", list_prefix);
@@ -288,7 +296,7 @@ int FileList::read_frame(VFrame *frame)
 
                FILE *in;
 
-// Fix path for VFS
+// Fix path for VFS.  Not used anymore.
                if(!strncmp(asset->path, RENDERFARM_FS_PREFIX, strlen(RENDERFARM_FS_PREFIX)))
                        sprintf(string, "%s%s", RENDERFARM_FS_PREFIX, path);
                else
@@ -392,38 +400,9 @@ int FileList::read_frame(VFrame *frame)
 
                if(!temp) return result;
 
-// printf("FileList::read_frame frame=%d temp=%d\n",
-// frame->get_color_model(),
-// temp->get_color_model());
-               if(frame->get_color_model() == temp->get_color_model())
-               {
-                       frame->copy_from(temp);
-               }
-               else
-               {
-// Never happens
-                       BC_CModels::transfer(frame->get_rows(), /* Leave NULL if non existent */
-                               temp->get_rows(),
-                               frame->get_y(), /* Leave NULL if non existent */
-                               frame->get_u(),
-                               frame->get_v(),
-                               temp->get_y(), /* Leave NULL if non existent */
-                               temp->get_u(),
-                               temp->get_v(),
-                               0,        /* Dimensions to capture from input frame */
-                               0,
-                               asset->width,
-                               asset->height,
-                               0,       /* Dimensions to project on output frame */
-                               0,
-                               asset->width,
-                               asset->height,
-                               temp->get_color_model(),
-                               frame->get_color_model(),
-                               0,         /* When transfering BC_RGBA8888 to non-alpha this is the background color in 0xRRGGBB hex */
-                               temp->get_w(),       /* For planar use the luma rowspan */
-                               frame->get_w());
-               }
+//printf("FileList::read_frame frame=%d temp=%d\n",
+// frame->get_color_model(), // temp->get_color_model());
+               frame->transfer_from(temp);
        }