- Timestamp:
- Sep 15, 2024, 1:33:59 AM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Server/server.c
r28 r29 487 487 addstring(&str, " </tr>\n"); 488 488 if(items != NULL) { 489 int phase = 0; 490 doit: 489 491 for(i = 0; items[i] != NULL; i++) { 490 492 char* fpth = cm_strcat3(path, "/", items[i]); … … 493 495 size[0] = 0; 494 496 stat(fpth, &s); 495 if(s.st_size < 1024ULL){ 497 if(phase == 0 && !S_ISDIR(s.st_mode)) { 498 free(fpth); 499 continue; 500 } else if(phase == 1 && S_ISDIR(s.st_mode)) { 501 free(fpth); 502 continue; 503 } 504 if(s.st_size < 1024ULL) { 496 505 sprintf(size, "%d", s.st_size); 497 } else if(s.st_size < 1024ULL * 1024){498 sprintf(size, "%.1f 499 } else if(s.st_size < 1024ULL * 1024 * 1024){500 sprintf(size, "%.1f 501 } else if(s.st_size < 1024ULL * 1024 * 1024 * 1024){502 sprintf(size, "%.1f 503 } else if(s.st_size < 1024ULL * 1024 * 1024 * 1024 * 1024){504 sprintf(size, "%.1f 506 } else if(s.st_size < 1024ULL * 1024) { 507 sprintf(size, "%.1fK", (double)s.st_size / 1024); 508 } else if(s.st_size < 1024ULL * 1024 * 1024) { 509 sprintf(size, "%.1fM", (double)s.st_size / 1024 / 1024); 510 } else if(s.st_size < 1024ULL * 1024 * 1024 * 1024) { 511 sprintf(size, "%.1fG", (double)s.st_size / 1024 / 1024 / 1024); 512 } else if(s.st_size < 1024ULL * 1024 * 1024 * 1024 * 1024) { 513 sprintf(size, "%.1fT", (double)s.st_size / 1024 / 1024 / 1024 / 1024); 505 514 } 506 515 … … 521 530 if(strcmp(items[i], "../") == 0) { 522 531 mime = "misc/parent"; 532 size[0] = 0; 523 533 } else if(items[i][strlen(items[i]) - 1] == '/') { 524 534 mime = "misc/dir"; 525 }else{ 535 size[0] = 0; 536 } else { 526 537 showmime = mime; 527 538 } … … 546 557 addstring(&str, " <td><img src=\"%s\" alt=\"icon\"></td>\n", icon); 547 558 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);559 addstring(&str, " <td><code>  %h  </code></td>\n", showmime); 560 addstring(&str, " <td><code>  %s  </code></td>\n", size); 550 561 addstring(&str, "</tr>\n"); 551 562 free(itm); 552 563 } 564 phase++; 565 if(phase != 2) goto doit; 566 for(i = 0; items[i] != NULL; i++) free(items[i]); 567 free(items); 553 568 } 554 569 addstring(&str, " </table>\n");
Note:
See TracChangeset
for help on using the changeset viewer.