From: Andre Noll Date: Wed, 12 Mar 2008 21:57:24 +0000 (+0100) Subject: Add new ls option: -lc to print out the chunk table. X-Git-Tag: v0.3.2~65 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=b290f23a898fb85446a36e0fa4ae83b647a4afd0;p=paraslash.git Add new ls option: -lc to print out the chunk table. --- diff --git a/aft.c b/aft.c index 0e3f83e8..0efd285c 100644 --- a/aft.c +++ b/aft.c @@ -58,7 +58,9 @@ enum ls_listing_mode { /** -lv */ LS_MODE_VERBOSE, /** -lm */ - LS_MODE_MBOX + LS_MODE_MBOX, + /** -lc */ + LS_MODE_CHUNKS }; /** The flags accepted by the ls command. */ @@ -819,6 +821,35 @@ static char *make_filename_lines(const char *path, unsigned flags) return ret; } +static int print_chunk_table(struct ls_data *d, struct para_buffer *b) +{ + struct osl_object chunk_table_obj; + struct osl_row *aft_row; + int ret, i; + char *buf; + + ret = aft_get_row_of_hash(d->hash, &aft_row); + if (ret < 0) + return ret; + ret = osl_open_disk_object(audio_file_table, aft_row, + AFTCOL_CHUNKS, &chunk_table_obj); + if (ret < 0) + return ret; + buf = chunk_table_obj.data; + para_printf(b, "%s\n" + "chunk_time: %lu:%lu\nchunk_offsets: ", + d->path, + (long unsigned) d->afhi.chunk_tv.tv_sec, + (long unsigned) d->afhi.chunk_tv.tv_usec + ); + for (i = 0; i <= d->afhi.chunks_total; i++) + para_printf(b, "%u ", + (unsigned) read_u32(buf + 4 * i)); + osl_close_disk_object(&chunk_table_obj); + para_printf(b, "\n"); + return 1; +} + static int print_list_item(struct ls_data *d, struct ls_options *opts, struct para_buffer *b, time_t current_time) { @@ -838,6 +869,8 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts, para_printf(b, "%s\n", d->path); return 1; } + if (opts->mode == LS_MODE_CHUNKS) + return print_chunk_table(d, b); get_attribute_bitmap(&afsi->attributes, att_buf); ret = get_local_time(&afsi->last_played, last_played_time, sizeof(last_played_time), current_time, opts->mode); @@ -1299,6 +1332,9 @@ int com_ls(int fd, int argc, char * const * const argv) case 'm': mode = LS_MODE_MBOX; continue; + case 'c': + mode = LS_MODE_CHUNKS; + continue; default: return -E_AFT_SYNTAX; }