Index: trunk/src_3rd/libucdf/ucdf.c =================================================================== --- trunk/src_3rd/libucdf/ucdf.c (revision 35431) +++ trunk/src_3rd/libucdf/ucdf.c (revision 35432) @@ -360,6 +360,27 @@ return res; } +/* Set up the virtual long file that holds short sector data */ +static int ucdf_setup_ssd(ucdf_ctx_t *ctx) +{ + long id_per_sect = ctx->sect_size >> 2; + + if (ctx->root->type != UCDF_DE_ROOT) + error(UCDF_ERR_BAD_DIRCHAIN); + + strcpy(ctx->ssd_de.name, "__short_sector_data__"); + ctx->ssd_de.type = UCDF_DE_FILE; + ctx->ssd_de.size = ctx->ssat_len * id_per_sect; + ctx->ssd_de.is_short = 0; + ctx->ssd_de.first = ctx->root->first; + ctx->ssd_de.parent = ctx->ssd_de.next = ctx->ssd_de.children = NULL; + + ctx->ssd_f.ctx = ctx; + ctx->ssd_f.de = &ctx->ssd_de; + ctx->ssd_f.stream_offs = ctx->ssd_f.sect_id = ctx->ssd_f.sect_offs = 0; + return 0; +} + int ucdf_open(ucdf_ctx_t *ctx, const char *path) { ctx->f = fopen(path, "rb"); @@ -377,6 +398,9 @@ if (ucdf_read_dirs(ctx) != 0) goto error; + if (ucdf_setup_ssd(ctx) != 0) + goto error; + return 0; error:; Index: trunk/src_3rd/libucdf/ucdf.h =================================================================== --- trunk/src_3rd/libucdf/ucdf.h (revision 35431) +++ trunk/src_3rd/libucdf/ucdf.h (revision 35432) @@ -78,6 +78,10 @@ long *msat; /* the master SAT read into memory */ long *sat; /* the whole SAT assembled and read into memory; entries are indexed by sector ID and contain the next sector ID within the chain */ long *ssat; /* the whole Short-SAT assembled and read into memory */ + + /* short sector data is really stored in a long stream; keep a file open on it */ + ucdf_direntry_t ssd_de; + ucdf_file_t ssd_f; };