added function BLI_filepathsize - so you dont have to open the file to get its size.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 21 Jan 2008 22:10:20 +0000 (22:10 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 21 Jan 2008 22:10:20 +0000 (22:10 +0000)
made render Touch function remove the touched file if the animation is canceled.

source/blender/blenlib/BLI_blenlib.h
source/blender/blenlib/intern/bpath.c
source/blender/blenlib/intern/storage.c
source/blender/render/intern/source/pipeline.c
source/blender/src/buttons_scene.c

index fed513d32796350590565a3a5570714fcbfb4889..4fc4241e6dca94a6b87c10be80efefcafb03fa2b 100644 (file)
@@ -272,6 +272,7 @@ int BLI_getInstallationDir(char *str);
                
 /* BLI_storage.h */
 int    BLI_filesize(int file);
+int    BLI_filepathsize(const char *path);
 double BLI_diskfree(char *dir);
 char *BLI_getwdN(char *dir);
 void BLI_hide_dot_files(int set);
index a6c71a836f59d9f3aa0944feaaa04fbb0b8b6c09..219ca424df870a0d77a50d6655899f6cd7fc50a0 100644 (file)
@@ -458,7 +458,6 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char
 {
        /* file searching stuff */
        DIR *dir;
-       int file = 0;
        struct dirent *de;
        struct stat status;
        char path[FILE_MAX];
@@ -485,14 +484,10 @@ static int findFileRecursive(char *filename_new, const char *dirname, const char
                if (S_ISREG(status.st_mode)) { /* is file */
                        if (strncmp(filename, de->d_name, FILE_MAX)==0) { /* name matches */
                                /* open the file to read its size */
-                               file = open(path, O_BINARY|O_RDONLY);
-                               if (file >=0 ) {
-                                       size = BLI_filesize(file);
-                                       if (size > *filesize) { /* find the biggest file */
-                                               *filesize = size;
-                                               BLI_strncpy(filename_new, path, FILE_MAX);
-                                       }
-                                       close(file);
+                               size = BLI_filepathsize(path);
+                               if ((size > 0) && (size > *filesize)) { /* find the biggest file */
+                                       *filesize = size;
+                                       BLI_strncpy(filename_new, path, FILE_MAX);
                                }
                        }
                } else if (S_ISDIR(status.st_mode)) { /* is subdir */
index 1d46679cbf243e52578125bb0ac2e1ab6f5402ed..c6011bb6fd999dac80e6c6312793449bd51b5939 100644 (file)
@@ -472,6 +472,17 @@ int BLI_filesize(int file)
        return (buf.st_size);
 }
 
+int BLI_filepathsize(const char *path)
+{
+       int size, file = open(path, O_BINARY|O_RDONLY);
+       
+       if (file <= 0)
+               return -1;
+       
+       size = BLI_filesize(file);
+       close(file);
+       return size;
+}
 
 
 int BLI_exist(char *name)
index b8e3091ae4a55bde4c60a82fee689bf253f0c032..43f0a0d13e7d25443ac7fa8c66a563ccec896aa8 100644 (file)
@@ -2369,7 +2369,14 @@ void RE_BlenderAnim(Render *re, Scene *scene, int sfra, int efra)
                                do_write_image_or_movie(re, scene, mh);
                        }
                
-                       if(G.afbreek==1) break;
+                       if(G.afbreek==1) {
+                               /* remove touched file */
+                               if (scene->r.mode & R_TOUCH && BLI_exist(name) && BLI_filepathsize(name) == 0) {
+                                       BLI_delete(name, 0, 0);
+                               }
+                               
+                               break;
+                       }
                }
        }
        
index c3209dfa8148819726d1bed85d480344a9defd6f..b8ec72eff8c592b507e6f8a04b288ce713379fe1 100644 (file)
@@ -1837,8 +1837,8 @@ static void render_panel_output(void)
        uiBlockEndAlign(block);
        
        uiBlockBeginAlign(block);
-       uiDefButBitI(block, TOG, R_NO_OVERWRITE, B_NOP, "No Overwrite", 10, 142, 90, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Skip rendering frames when the file exists (image output only)");
-       uiDefButBitI(block, TOG, R_TOUCH, B_NOP, "Touch", 100, 142, 50, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Create an empty file before rendering each frame");
+       uiDefButBitI(block, TOG, R_TOUCH, B_NOP, "Touch", 10, 142, 50, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Create an empty file before rendering each frame, remove if cancelled (and empty)");
+       uiDefButBitI(block, TOG, R_NO_OVERWRITE, B_NOP, "No Overwrite", 60, 142, 90, 20, &G.scene->r.mode, 0.0, 0.0, 0, 0, "Skip rendering frames when the file exists (image output only)");
        uiBlockEndAlign(block);
        
        /* SET BUTTON */