From 9afd71b968b96a08fa8611adc21eab937e67858f Mon Sep 17 00:00:00 2001 From: nobruinfo Date: Mon, 8 Sep 2025 14:17:55 +0200 Subject: [PATCH] #232 uploading single file on full storage --- src/tools/mega65_ftp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/tools/mega65_ftp.c b/src/tools/mega65_ftp.c index f7b8301..ecb1801 100644 --- a/src/tools/mega65_ftp.c +++ b/src/tools/mega65_ftp.c @@ -2872,11 +2872,25 @@ unsigned int count_total_clusters(unsigned int first_cluster) unsigned int find_contiguous_clusters(unsigned int total_clusters) { unsigned int start_cluster = 0; + unsigned int start_cluster_before = 0; while (1) { BOOL is_contiguous = TRUE; unsigned int cnt; + + start_cluster_before = start_cluster; start_cluster = find_free_cluster(start_cluster); + + // printf("start_cluster=%u start_cluster_before=%u\n", + // start_cluster, start_cluster_before); + + // find_free_cluster() above returns a lower number on rollover, so + // quitting on variable overflow indicating storage could be full: + if (start_cluster < start_cluster_before) { + fprintf(stderr, "ERROR: Could not allocate enough contiguous clusters %s", + "to create file/dir. Storage device may be full.\n"); + return FALSE; // 0 is caught in the caller method + } for (cnt = 1; cnt < total_clusters; cnt++) { if (!is_free_cluster(start_cluster + cnt)) {