Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 1dc8deb6 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Don't specify the mkvpropedit path with hard defined strings.

parent ce5d0e69
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!44Metadata write
...@@ -44,7 +44,7 @@ int kara_metadata_write(struct kara_metadata *mdt, const char *filename, ...@@ -44,7 +44,7 @@ int kara_metadata_write(struct kara_metadata *mdt, const char *filename,
const char *mkvpropedit); const char *mkvpropedit);
/* Set the metadata for the file according to its path. */ /* Set the metadata for the file according to its path. */
int metadata_set_file(char *karapath); int metadata_set_file(char *karapath, const char *mkvpropedit);
/* Set metadata for files under a given directory by their path. */ /* Set metadata for files under a given directory by their path. */
int metadata_set_directory(const char *kara_dir); int metadata_set_directory(const char *kara_dir, const char *mkvpropedit);
...@@ -31,7 +31,7 @@ main(int argc, char *argv[]) ...@@ -31,7 +31,7 @@ main(int argc, char *argv[])
sqlite3 *db; sqlite3 *db;
bool ret = true; bool ret = true;
lkt_config_t conf; lkt_config_t conf;
char kara_dir[PATH_MAX], *db_path; char kara_dir[PATH_MAX], *db_path, *mkvpropedit;
struct kara_metadata data; struct kara_metadata data;
struct lkt_repo repo; struct lkt_repo repo;
...@@ -45,6 +45,12 @@ main(int argc, char *argv[]) ...@@ -45,6 +45,12 @@ main(int argc, char *argv[])
return 1; return 1;
} }
/* In any case, we won't free the mkvpropedit, this is not a daemon. */
if (config_get_alloc(conf, "externals", "mkvpropedit", &mkvpropedit)) {
fprintf(stderr, " ! could not get the 'mkvpropedit property from the externals section\n'");
return 1;
}
/* Arguments handle. */ /* Arguments handle. */
if (strcmp(argv[1], "--init") == 0) { if (strcmp(argv[1], "--init") == 0) {
...@@ -53,7 +59,7 @@ main(int argc, char *argv[]) ...@@ -53,7 +59,7 @@ main(int argc, char *argv[])
return 10; return 10;
} }
return metadata_set_directory(kara_dir); return metadata_set_directory(kara_dir, mkvpropedit);
} }
else if (strcmp(argv[1], "--populate-all") == 0) { else if (strcmp(argv[1], "--populate-all") == 0) {
...@@ -82,14 +88,14 @@ end_populate: ...@@ -82,14 +88,14 @@ end_populate:
else if (strcmp(argv[1], "--file") == 0) { else if (strcmp(argv[1], "--file") == 0) {
ret = 0; ret = 0;
for (i = 2; i < argc; ++i) for (i = 2; i < argc; ++i)
ret |= metadata_set_file(argv[i]); ret |= metadata_set_file(argv[i], mkvpropedit);
return ret; return ret;
} }
else if (strcmp(argv[1], "--prompt-file") == 0) { else if (strcmp(argv[1], "--prompt-file") == 0) {
ret = 0; ret = 0;
for (i = 2; i < argc; ++i) for (i = 2; i < argc; ++i)
ret |= metadata_set_file(argv[i]); ret |= metadata_set_file(argv[i], mkvpropedit);
return ret; return ret;
} }
......
...@@ -53,8 +53,7 @@ static const char *METADATA_TEMPLATE = ...@@ -53,8 +53,7 @@ static const char *METADATA_TEMPLATE =
" <String>%d</String> " " <String>%d</String> "
" </Simple> " " </Simple> "
" </Tag> " " </Tag> "
" </Tags> " " </Tags> ";
;
static bool static bool
mkvpropedit__(const char *const args[]) mkvpropedit__(const char *const args[])
...@@ -248,7 +247,7 @@ error: ...@@ -248,7 +247,7 @@ error:
} }
int int
metadata_set_directory(const char *kara_dir) metadata_set_directory(const char *kara_dir, const char *mkvpropedit)
{ {
DIR *d; DIR *d;
struct dirent *dir; struct dirent *dir;
...@@ -271,12 +270,12 @@ metadata_set_directory(const char *kara_dir) ...@@ -271,12 +270,12 @@ metadata_set_directory(const char *kara_dir)
if (dir->d_type == DT_REG && if (dir->d_type == DT_REG &&
metadata_from_path(path, &meta) && metadata_from_path(path, &meta) &&
kara_metadata_write(&meta, path, "/usr/bin/mkvpropedit")) kara_metadata_write(&meta, path, mkvpropedit))
continue; continue;
else if (dir->d_type == DT_DIR && else if (dir->d_type == DT_DIR &&
strcmp(dir->d_name, ".") != 0 && strcmp(dir->d_name, ".") != 0 &&
strcmp(dir->d_name, "..") != 0) strcmp(dir->d_name, "..") != 0)
metadata_set_directory(path); metadata_set_directory(path, mkvpropedit);
} }
fprintf(stderr, " * metadata_set_directory: Passed directory '%s'\n", kara_dir); fprintf(stderr, " * metadata_set_directory: Passed directory '%s'\n", kara_dir);
...@@ -285,11 +284,11 @@ metadata_set_directory(const char *kara_dir) ...@@ -285,11 +284,11 @@ metadata_set_directory(const char *kara_dir)
} }
int int
metadata_set_file(char *karapath) metadata_set_file(char *karapath, const char *mkvpropedit)
{ {
struct kara_metadata meta; struct kara_metadata meta;
return metadata_from_path(karapath, &meta) && return metadata_from_path(karapath, &meta) &&
kara_metadata_write(&meta, karapath, "/usr/bin/mkvpropedit"); kara_metadata_write(&meta, karapath, mkvpropedit);
} }
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter