Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/BLI_filelist.c')
-rw-r--r--source/blender/blenlib/intern/BLI_filelist.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index e9ed785efc7..f700a12fbca 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -218,7 +218,6 @@ 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;
struct direntry *file;
struct tm *tm;
time_t zero = 0;
@@ -288,20 +287,25 @@ 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;
+ file->realsize = 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));
- }
- else if (st_size > 1024 * 1024) {
- BLI_snprintf(file->size, sizeof(file->size), "%.1f MiB", ((double)st_size) / (1024 * 1024));
- }
- else if (st_size > 1024) {
- BLI_snprintf(file->size, sizeof(file->size), "%d KiB", (int)(st_size / 1024));
- }
- else {
- BLI_snprintf(file->size, sizeof(file->size), "%d B", (int)st_size);
- }
+ BLI_file_size_string(file->realsize, file->size, sizeof(file->size));
+ }
+}
+
+void BLI_file_size_string(off_t st_size, char *size, size_t len)
+{
+ if (st_size > 1024 * 1024 * 1024) {
+ BLI_snprintf(size, len, "%.2f GiB", ((double)st_size) / (1024 * 1024 * 1024));
+ }
+ else if (st_size > 1024 * 1024) {
+ BLI_snprintf(size, len, "%.1f MiB", ((double)st_size) / (1024 * 1024));
+ }
+ else if (st_size > 1024) {
+ BLI_snprintf(size, len, "%d KiB", (int)(st_size / 1024));
+ }
+ else {
+ BLI_snprintf(size, len, "%d B", (int)st_size);
}
}
@@ -361,6 +365,9 @@ void BLI_filelist_duplicate(
if (dest->poin && dup_poin) {
dest->poin = dup_poin(src->poin);
}
+ if (dest->collapsed_info.darray) {
+ dest->collapsed_info.darray = NULL;
+ }
}
}
@@ -381,6 +388,8 @@ void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries, void (
MEM_freeN(entry->path);
if (entry->poin && free_poin)
free_poin(entry->poin);
+ if (entry->collapsed_info.darray)
+ MEM_freeN(entry->collapsed_info.darray);
}
if (filelist != NULL) {