diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c index e9ed785efc7..786eaa74df8 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); } } }