diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-01-22 01:10:20 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-01-22 01:10:20 +0300 |
commit | 643e29c7362305d37a3bbfc82e9654653ff4884a (patch) | |
tree | cd6eea2f153fc3bf195e2d62fd33c40166090319 /source | |
parent | 9dd1bcfdfb3e32b57aee6ee7c1e2f0f5d2446da9 (diff) |
added function BLI_filepathsize - so you dont have to open the file to get its size.
made render Touch function remove the touched file if the animation is canceled.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_blenlib.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/bpath.c | 13 | ||||
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 11 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 9 | ||||
-rw-r--r-- | source/blender/src/buttons_scene.c | 4 |
5 files changed, 26 insertions, 12 deletions
diff --git a/source/blender/blenlib/BLI_blenlib.h b/source/blender/blenlib/BLI_blenlib.h index fed513d3279..4fc4241e6dc 100644 --- a/source/blender/blenlib/BLI_blenlib.h +++ b/source/blender/blenlib/BLI_blenlib.h @@ -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); diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index a6c71a836f5..219ca424df8 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -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 */ diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 1d46679cbf2..c6011bb6fd9 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -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) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index b8e3091ae4a..43f0a0d13e7 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -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; + } } } diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index c3209dfa814..b8ec72eff8c 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -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 */ |