- Timestamp:
- Sep 15, 2024, 1:25:08 AM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/server.c
r24 r28 483 483 addstring(&str, " <th></th>\n"); 484 484 addstring(&str, " <th>Filename</th>\n"); 485 addstring(&str, " <th>MIME</th>\n"); 486 addstring(&str, " <th>Size</th>\n"); 485 487 addstring(&str, " </tr>\n"); 486 488 if(items != NULL) { 487 489 for(i = 0; items[i] != NULL; i++) { 490 char* fpth = cm_strcat3(path, "/", items[i]); 491 struct stat s; 492 char size[512]; 493 size[0] = 0; 494 stat(fpth, &s); 495 if(s.st_size < 1024ULL){ 496 sprintf(size, "%d", s.st_size); 497 }else if(s.st_size < 1024ULL * 1024){ 498 sprintf(size, "%.1f K", (double)s.st_size / 1024); 499 }else if(s.st_size < 1024ULL * 1024 * 1024){ 500 sprintf(size, "%.1f M", (double)s.st_size / 1024 / 1024); 501 }else if(s.st_size < 1024ULL * 1024 * 1024 * 1024){ 502 sprintf(size, "%.1f G", (double)s.st_size / 1024 / 1024 / 1024); 503 }else if(s.st_size < 1024ULL * 1024 * 1024 * 1024 * 1024){ 504 sprintf(size, "%.1f T", (double)s.st_size / 1024 / 1024 / 1024 / 1024); 505 } 506 507 free(fpth); 508 488 509 char* ext = NULL; 489 510 int j; … … 496 517 } 497 518 } 519 char* showmime = ""; 498 520 char* mime = tw_get_mime(ext, vhost_entry); 499 521 if(strcmp(items[i], "../") == 0) { … … 501 523 } else if(items[i][strlen(items[i]) - 1] == '/') { 502 524 mime = "misc/dir"; 525 }else{ 526 showmime = mime; 503 527 } 504 528 char* icon = tw_get_icon(mime, vhost_entry); … … 522 546 addstring(&str, " <td><img src=\"%s\" alt=\"icon\"></td>\n", icon); 523 547 addstring(&str, " <td><a href=\"%l\"><code>%h</code></a></td>\n", items[i], itm); 548 addstring(&str, " <td><code>%h</code></td>\n", showmime); 549 addstring(&str, " <td><code>%s</code></td>\n", size); 524 550 addstring(&str, "</tr>\n"); 525 551 free(itm);
Note:
See TracChangeset
for help on using the changeset viewer.