static int fat_construct_converted_tree (FatOpContext* ctx) { FatSpecific* old_fs_info = FAT_SPECIFIC (ctx->old_fs); FatSpecific* new_fs_info = FAT_SPECIFIC (ctx->new_fs); FatTraverseInfo* old_trav_info; FatTraverseInfo* new_trav_info; if (new_fs_info->fat_type == FAT_TYPE_FAT32) { new_trav_info = fat_traverse_begin (ctx->new_fs, new_fs_info->root_cluster, "\\"); old_trav_info = fat_traverse_begin (ctx->old_fs, FAT_ROOT, "\\"); } else { fat_clear_root_dir (ctx->new_fs); new_trav_info = fat_traverse_begin (ctx->new_fs, FAT_ROOT, "\\"); old_trav_info = fat_traverse_begin (ctx->old_fs, old_fs_info->root_cluster, "\\"); } if (!new_trav_info || !old_trav_info) return 0; if (!fat_convert_directory (ctx, old_trav_info, new_trav_info)) return 0; return 1; }
/* Constructs the new directory tree for legacy (FAT16) file systems. */ static int fat_construct_legacy_root (FatOpContext* ctx) { FatTraverseInfo* trav_info; if (!duplicate_legacy_root_dir (ctx)) return 0; trav_info = fat_traverse_begin (ctx->new_fs, FAT_ROOT, "\\"); return fat_construct_directory (ctx, trav_info); }
/* Constructs the new directory tree for new (FAT32) file systems. */ static int fat_construct_root (FatOpContext* ctx) { FatSpecific* new_fs_info = FAT_SPECIFIC (ctx->new_fs); FatTraverseInfo* trav_info; trav_info = fat_traverse_begin (ctx->new_fs, new_fs_info->root_cluster, "\\"); fat_construct_directory (ctx, trav_info); return 1; }
FatTraverseInfo* fat_traverse_directory (FatTraverseInfo *trav_info, FatDirEntry* parent) { strcpy (tmp_buffer, trav_info->dir_name); fat_dir_entry_get_name (parent, tmp_buffer + strlen (trav_info->dir_name)); strcat (tmp_buffer, "\\"); return fat_traverse_begin (trav_info->fs, fat_dir_entry_get_first_cluster (parent, trav_info->fs), tmp_buffer); }