X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aft.c;h=5f5548f03dc9e71989fddf41acb4cb16b568910c;hp=001026db4e956caa8b46256797d29cddced6ddf5;hb=11688f127edbe447586de3868c268da15492a8d3;hpb=4a33aa7ad93857d0c6b5ea24983e12b1619b10c0 diff --git a/aft.c b/aft.c index 001026db..5f5548f0 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; + 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 + ); + buf = chunk_table_obj.data; + 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; } @@ -1869,6 +1905,8 @@ struct touch_action_data { struct com_touch_options *cto; /** Message buffer. */ struct para_buffer pb; + /** How many audio files matched the given pattern. */ + unsigned num_matches; }; static int touch_audio_file(__a_unused struct osl_table *table, @@ -1911,6 +1949,7 @@ static int touch_audio_file(__a_unused struct osl_table *table, if (tad->cto->last_played >= 0) new_afsi.last_played = tad->cto->last_played; } + tad->num_matches++; save_afsi(&new_afsi, &obj); /* in-place update */ aced.aft_row = row; aced.old_afsi = &old_afsi; @@ -1937,6 +1976,9 @@ static int com_touch_callback(const struct osl_object *query, ret = for_each_matching_row(&pmd); if (ret < 0) para_printf(&tad.pb, "%s\n", para_strerror(-ret)); + else + if (!tad.num_matches) + para_printf(&tad.pb, "no matches\n"); if (tad.pb.buf) { result->data = tad.pb.buf; result->size = tad.pb.size;