From: Andre Noll Date: Thu, 13 Sep 2007 17:09:24 +0000 (+0200) Subject: com_add: Minor improvements. X-Git-Tag: v0.3.0~422 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=727ae07c46980a5115f9085bee6c72ef3109c8bb com_add: Minor improvements. Continue if an audio file could not be added and print proper error message in case of errors. --- diff --git a/aft.c b/aft.c index 9ec97761..82724c3d 100644 --- a/aft.c +++ b/aft.c @@ -1456,11 +1456,8 @@ static int add_one_audio_file(const char *arg, const void *private_data) */ if (!hs || (pad->flags & ADD_FLAG_FORCE)) { ret = compute_afhi(path, map.data, map.size, &afhi); - if (ret < 0) { - ret = send_va_buffer(pad->fd, - "audio format of %s not recognized\n", path); + if (ret < 0) goto out_unmap; - } format_num = ret; afhi_ptr = &afhi; } @@ -1473,6 +1470,9 @@ static int add_one_audio_file(const char *arg, const void *private_data) out_unmap: munmap(map.data, map.size); out_free: + if (ret < 0) + send_va_buffer(pad->fd, "failed to add %s (%s)\n", path, + PARA_STRERROR(-ret)); free(obj.data); free(path); if (afhi_ptr) @@ -1517,16 +1517,11 @@ int com_add(int fd, int argc, char * const * const argv) if (S_ISDIR(statbuf.st_mode)) { ret = for_each_file_in_dir(argv[i], add_one_audio_file, &pad); - if (ret < 0) - return ret; continue; } ret = add_one_audio_file(argv[i], &pad); - if (ret < 0) - goto out; } ret = 1; -out: return ret; } diff --git a/error.h b/error.h index 9bc8ed52..1be0536e 100644 --- a/error.h +++ b/error.h @@ -131,15 +131,15 @@ extern const char **para_errlist[]; PARA_ERROR(INDEX_CORRUPTION, "fixme"), \ PARA_ERROR(BAD_OFFSET, "fixme"), \ PARA_ERROR(INVALID_OBJECT, "fixme"), \ - PARA_ERROR(MKDIR, "fixme"), \ - PARA_ERROR(OPEN, "fixme"), \ - PARA_ERROR(STAT, "fixme"), \ - PARA_ERROR(FSTAT, "fixme"), \ + PARA_ERROR(MKDIR, "failed to create directory"), \ + PARA_ERROR(OPEN, "failed to open file"), \ + PARA_ERROR(STAT, "can not stat file"), \ + PARA_ERROR(FSTAT, "fstat error"), \ PARA_ERROR(RENAME, "fixme"), \ - PARA_ERROR(EMPTY, "fixme"), \ + PARA_ERROR(EMPTY, "file empty"), \ PARA_ERROR(NOSPC, "fixme"), \ - PARA_ERROR(MMAP, "fixme"), \ - PARA_ERROR(MUNMAP, "fixme"), \ + PARA_ERROR(MMAP, "mmap error"), \ + PARA_ERROR(MUNMAP, "munmap failed"), \ PARA_ERROR(WRITE, "fixme"), \ PARA_ERROR(LSEEK, "fixme"), \ PARA_ERROR(BUSY, "fixme"), \