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.
This commit is contained in:
Campbell Barton
2008-01-21 22:10:20 +00:00
parent 9dd1bcfdfb
commit 643e29c736
5 changed files with 26 additions and 12 deletions

View 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);

View 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 */

View 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)

View 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;
}
}
}

View 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 */