X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aft.c;h=0e3f83e85524b3fea16d64bb612f10a3e9189abd;hp=0bf38fe691838b78cc35a1a8cde344147b5d4f47;hb=7ed44d3d7ff3df2a78d80db2586a412de595e255;hpb=c8862b9e246b4ef6ff1fe103946e18cf2537ecde diff --git a/aft.c b/aft.c index 0bf38fe6..0e3f83e8 100644 --- a/aft.c +++ b/aft.c @@ -660,6 +660,7 @@ int open_and_update_audio_file(struct osl_row *aft_row, long score, AFTCOL_CHUNKS, &chunk_table_obj); if (ret < 0) return ret; + afd->afhi.chunk_table = NULL; ret = mmap_full_file(path, O_RDONLY, &map.data, &map.size, &afd->fd); if (ret < 0) @@ -697,10 +698,8 @@ int open_and_update_audio_file(struct osl_row *aft_row, long score, aced.old_afsi = &old_afsi; afs_event(AFSI_CHANGE, NULL, &aced); ret = save_afd(afd); - free(afd->afhi.chunk_table); - if (ret < 0) - goto err; err: + free(afd->afhi.chunk_table); osl_close_disk_object(&chunk_table_obj); return ret; } @@ -1870,6 +1869,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, @@ -1912,6 +1913,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; @@ -1938,6 +1940,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; @@ -2005,11 +2010,14 @@ int com_touch(int fd, int argc, char * const * const argv) return -E_AFT_SYNTAX; ret = send_option_arg_callback_request(&query, argc - i, argv + i, com_touch_callback, &result); - if (ret > 0) { - send_buffer(fd, (char *)result.data); - free(result.data); - } else if (ret < 0) + if (!ret) + return 0; + if (ret < 0) { send_va_buffer(fd, "%s\n", para_strerror(-ret)); + return ret; + } + ret = send_buffer(fd, (char *)result.data); + free(result.data); return ret; } @@ -2117,11 +2125,14 @@ int com_rm(int fd, int argc, char * const * const argv) return -E_AFT_SYNTAX; ret = send_option_arg_callback_request(&query, argc - i, argv + i, com_rm_callback, &result); - if (ret > 0) { - send_buffer(fd, (char *)result.data); - free(result.data); - } else if (ret < 0) + if (!ret) + return 0; + if (ret < 0) { send_va_buffer(fd, "%s\n", para_strerror(-ret)); + return ret; + } + ret = send_buffer(fd, (char *)result.data); + free(result.data); return ret; } @@ -2278,11 +2289,14 @@ int com_cpsi(int fd, int argc, char * const * const argv) flags = ~(unsigned)CPSI_FLAG_VERBOSE | flags; ret = send_option_arg_callback_request(&options, argc - i, argv + i, com_cpsi_callback, &result); - if (ret > 0) { - send_buffer(fd, (char *)result.data); - free(result.data); - } else + if (!ret) + return 0; + if (ret < 0) { send_va_buffer(fd, "%s\n", para_strerror(-ret)); + return ret; + } + ret = send_buffer(fd, (char *)result.data); + free(result.data); return ret; }