Commit: aac5485fcac6736f6ded186ed8d2ec8743d08de0
Author: Bastien Montagne
Date: Sat Jun 27 23:39:48 2015 +0200
Branches: master
https://developer.blender.org/rBaac5485fcac6736f6ded186ed8d2ec8743d08de0
Fix T45216: File Browser shows negative sizes for large files.
Simply backport small part of work from asset-experiments here (using double and
adding tera-bytes unit), looks like off_t is not always 64bits even on a 64bit
OS...
===================================================================
M source/blender/blenlib/intern/BLI_filelist.c
===================================================================
diff --git a/source/blender/blenlib/intern/BLI_filelist.c
b/source/blender/blenlib/intern/BLI_filelist.c
index e9ed785..786eaa7 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -218,7 +218,7 @@ static void bli_adddirstrings(struct BuildDirCtx *dir_ctx)
const char *types[8] = {"---", "--x", "-w-", "-wx", "r--", "r-x",
"rw-", "rwx"};
/* symbolic display, indexed by mode field value */
int num;
- off_t st_size;
+ double size;
struct direntry *file;
struct tm *tm;
time_t zero = 0;
@@ -288,19 +288,22 @@ static void bli_adddirstrings(struct BuildDirCtx *dir_ctx)
* will buy us some time until files get bigger than 4GB or
until
* everyone starts using __USE_FILE_OFFSET64 or equivalent.
*/
- st_size = file->s.st_size;
+ size = (double)file->s.st_size;
- if (st_size > 1024 * 1024 * 1024) {
- BLI_snprintf(file->size, sizeof(file->size), "%.2f
GiB", ((double)st_size) / (1024 * 1024 * 1024));
+ if (size > 1024.0 * 1024.0 * 1024.0 * 1024.0) {
+ BLI_snprintf(file->size, sizeof(file->size), "%.1f
TiB", size / (1024.0 * 1024.0 * 1024.0 * 1024.0));
}
- else if (st_size > 1024 * 1024) {
- BLI_snprintf(file->size, sizeof(file->size), "%.1f
MiB", ((double)st_size) / (1024 * 1024));
+ else if (size > 1024.0 * 1024.0 * 1024.0) {
+ BLI_snprintf(file->size, sizeof(file->size), "%.1f
GiB", size / (1024.0 * 1024.0 * 1024.0));
}
- else if (st_size > 1024) {
- BLI_snprintf(file->size, sizeof(file->size), "%d KiB",
(int)(st_size / 1024));
+ else if (size > 1024.0 * 1024.0) {
+ BLI_snprintf(file->size, sizeof(file->size), "%.1f
MiB", size / (1024.0 * 1024.0));
+ }
+ else if (size > 1024.0) {
+ BLI_snprintf(file->size, sizeof(file->size), "%.1f
KiB", size / 1024.0);
}
else {
- BLI_snprintf(file->size, sizeof(file->size), "%d B",
(int)st_size);
+ BLI_snprintf(file->size, sizeof(file->size), "%d B",
(int)size);
}
}
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs