From 27a3ff3d8621c9f51d2dbf71bd39f44c4400e632 Mon Sep 17 00:00:00 2001 From: nobruinfo Date: Thu, 17 Jul 2025 17:42:29 +0200 Subject: [PATCH 1/2] #229 df for disk free as a separate command --- bin/README.md | 1 - src/tools/mega65_ftp.c | 23 +++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) delete mode 100644 bin/README.md diff --git a/bin/README.md b/bin/README.md deleted file mode 100644 index 60a28cf5..00000000 --- a/bin/README.md +++ /dev/null @@ -1 +0,0 @@ -Compiled programmes, all native. MEGA65 PRG are in bin65 (or their respective src dir) diff --git a/src/tools/mega65_ftp.c b/src/tools/mega65_ftp.c index f7b83019..6d4ab49a 100644 --- a/src/tools/mega65_ftp.c +++ b/src/tools/mega65_ftp.c @@ -143,6 +143,7 @@ void perform_filehost_get(int num, char *destname); void perform_filehost_flash(int fhnum, int slotnum); void perform_flash(char *fname, int slotnum); void list_all_roms(void); +void disk_free(void); int show_directory(char *path); int count_directory(char *path, int * dir_count, int * file_count); int purge_directory_or_file(char *path); @@ -572,6 +573,9 @@ int execute_command(char *cmd) else if (sscanf(cmd, "dirent_raw %d", &dirent_raw) == 1) { printf("dirent_raw = %d\n", dirent_raw); } + else if (!strcmp(cmd, "df")) { + disk_free(); + } else if (parse_command(cmd, "dir %s", src) == 1) { show_directory(src); } @@ -668,6 +672,7 @@ int execute_command(char *cmd) printf("dir [directory|wildcardpattern] - show contents of current or specified sdcard directory. Can use a wildcard " "pattern on current directory.\n"); printf("ldir [wildcardpattern] - shows the contents of current local directory.\n"); + printf("df - shows total disk usage on the sdcard.\n"); printf("cd [directory] - change current sdcard working directory.\n"); printf("lcd [directory] - change current local working directory.\n"); printf("put [destination name] - upload file to SD card, and optionally rename it destination file.\n"); @@ -3214,6 +3219,16 @@ char *get_datetime_str(struct tm *tm) return s; } +void disk_free(void) +{ + printf("This will take a while on larger cards.\n"); + printf("sdcard totals: "); + printf("%d out of %d MB free ", count_free_clusters(0) * 4 / 1024, + count_total_clusters(0) * 4 / 1024); + printf("(%d out of %d Cluster(s) free)\n", count_free_clusters(0), + count_total_clusters(0)); +} + int show_directory(char *path) { int dir_count = 0; @@ -3261,15 +3276,7 @@ int show_directory(char *path) cur = cur->next; } } while (0); -#ifdef TESTING - printf("%d Dir(s), %d File(s), ", dir_count, file_count); - printf("%d out of %d MB free ", count_free_clusters(0) * 4 / 1024, - count_total_clusters(0) * 4 / 1024); - printf("(%d out of %d Cluster(s) free)\n", count_free_clusters(0), - count_total_clusters(0)); -#else printf("%d Dir(s), %d File(s)\n", dir_count, file_count); -#endif llist_free(lst_dirents); From 942b0abcefe7365ca8946a9fe191fa4108541511 Mon Sep 17 00:00:00 2001 From: nobruinfo Date: Sun, 20 Jul 2025 18:21:48 +0200 Subject: [PATCH 2/2] #229 df for disk free as a separate command --- bin/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 bin/README.md diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 00000000..60a28cf5 --- /dev/null +++ b/bin/README.md @@ -0,0 +1 @@ +Compiled programmes, all native. MEGA65 PRG are in bin65 (or their respective src dir)