diff options
-rw-r--r-- | mg_item.c | 14 | ||||
-rw-r--r-- | mg_item_gd.c | 13 |
2 files changed, 24 insertions, 3 deletions
@@ -12,6 +12,7 @@ #include <unistd.h> #include <fcntl.h> #include <errno.h> +#include <stdlib.h> #include <cstring> #include "mg_item.h" @@ -59,6 +60,19 @@ mgItem::analyze_failure(string filename) const { readable(filename); // sets errno int err = errno; +#ifdef DEBUGSEL + if (err==ENOENT) { + char *command; + msprintf(&command,"cd '%s';%s/scripts/speak.sh '%s'>/dev/null 2>&1", + the_setup.ToplevelDir, + the_setup.ConfigDirectory.c_str(), + filename.c_str()); + system(command); + free(command); + readable(filename); // sets errno + err = errno; + } +#endif int nsize = filename.size(); const char *p; if (err==123456) diff --git a/mg_item_gd.c b/mg_item_gd.c index 83fe4ee..e6160c8 100644 --- a/mg_item_gd.c +++ b/mg_item_gd.c @@ -222,8 +222,9 @@ mgItemGd::getSourceFile(bool AbsolutePath,bool Silent) const continue; char *file; msprintf(&file,"%02d/%s",i,m_mp3file.c_str()); - if (readable(file)) { - m_mp3file = file; + string fstr = string(file); + if (readable(fstr)) { + m_mp3file = fstr; result = m_mp3file; } free(file); @@ -233,8 +234,14 @@ mgItemGd::getSourceFile(bool AbsolutePath,bool Silent) const } m_validated=true; if (result.empty()) { - if (!Silent) + if (!Silent) { analyze_failure(m_mp3file); + // in debug mode, analyze_failure might replace + // the missing file by a file which speaks the + // name of the missing file + if (readable(m_mp3file)) + return m_mp3file; + } m_valid = false; return m_mp3file; } |