+ if( preload_textbox ) {
+ preload_textbox = 0;
+ textbox->update(new_item->get_text());
+ }
+ int64_t size = file_item->size;
+ if( (size_format == FILEBOX_SIZE_1000 && size >= 1000) ||
+ (size_format == FILEBOX_SIZE_1024 && size >= 1024) ) {
+ static const char *suffix[] = { "", "K", "M", "G", "T", "P" };
+ if( size_format == FILEBOX_SIZE_1024 ) {
+ static const long double kk = logl(1000.)/logl(1024.);
+ size = expl(kk*logl((long double)size)) + 0.5;
+ }
+ int len = ilen(size), drop = len-3, round = 1;
+ if( round && drop > 0 ) { //round
+ size += ipow(10,drop)/2;
+ len = ilen(size); drop = len-3;
+ }
+ size /= ipow(10,drop);
+ int sfx = (len-1)/3;
+ int digits = (sfx+1)*3 - len;
+ int64_t frac = ipow(10,digits);
+ int mant = size / frac;
+ int fraction = size - mant*frac;
+ sfx = *suffix[sfx];
+ if( sfx && size_format == FILEBOX_SIZE_1000 ) sfx += 'a'-'A';
+ if( digits )
+ sprintf(string, "%d.%0*d%c", mant, digits, fraction, sfx);
+ else
+ sprintf(string, "%d%c", mant, sfx);
+ }
+ else {
+ sprintf(string, "%jd", size);
+ if( size_format == FILEBOX_SIZE_THOU )
+ Units::punctuate(string);
+ }