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/blender/blenlib | |
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/blender/blenlib')
-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 |
3 files changed, 16 insertions, 9 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) |