Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/tools/mega65_ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Loading