diff options
author | Wolfgang Rohdewald <wolfgang@rohdewald.de> | 2008-12-22 06:09:49 +0100 |
---|---|---|
committer | Wolfgang Rohdewald <wolfgang@rohdewald.de> | 2008-12-22 06:09:49 +0100 |
commit | e3fad1a508f4f0e0fa21bf0d32c1da71bcc7d0dc (patch) | |
tree | ecb8d8a4d78be906da069baee72ba0bcbd6e7341 | |
parent | 5f03b3a6324568a87397764a4408084931ab5d16 (diff) | |
download | vdr-plugin-muggle-e3fad1a508f4f0e0fa21bf0d32c1da71bcc7d0dc.tar.gz vdr-plugin-muggle-e3fad1a508f4f0e0fa21bf0d32c1da71bcc7d0dc.tar.bz2 |
fix bug #32 mugglei will not run from a linked subfolder
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | mg_db.c | 20 | ||||
-rw-r--r-- | mg_db.h | 2 | ||||
-rw-r--r-- | mugglei.c | 7 |
4 files changed, 18 insertions, 12 deletions
@@ -372,3 +372,4 @@ Balke. - update README.* about MySQL with utf8 - importing subdirectories with mugglei: sorting by folder did not work for those tracks. Found by Thomas Balke. +- fix bug #32 reported by Anonymous: mugglei will not run from a linked subfolder @@ -40,6 +40,18 @@ static map <mgKeyTypes, map<string,string> > map_ids; mgDbServer* DbServer; +const char * +mugglepath() { + char buf[5000]; + memset(buf,0,5000); + if (getenv("PWD")) + strncpy(buf,getenv("PWD"),4990); + else + getcwd(buf,4990); + strcat(buf,"/"); + return strdup(buf); +} + mgDbServer::mgDbServer() { #ifdef HAVE_SQLITE m_server = new mgDbServerSQLite; @@ -1198,18 +1210,14 @@ mgDb::SyncFile(const char *filename) { mgSQLString c_lang(m_TLAN); mgSQLString c_cddbid(getAlbum(filename,c_album,c_artist)); - char cwd[5000]; - if (!getcwd(cwd,4999)) { - std::cout << "Path too long" << std::endl; - exit (1); - } + const char *cwd = mugglepath(); int tldlen = strlen(the_setup.ToplevelDir); - strcat(cwd,"/"); int cwdlen = strlen(cwd); const char *relpath=cwd; if (cwdlen>tldlen); relpath += tldlen; char *b; msprintf(&b,"%s%s",relpath,cfilename); + free((void*)cwd); mgSQLString c_mp3file(b); char *folders[4]; char *fbuf=SeparateFolders(b,folders,4); @@ -39,6 +39,8 @@ strlist& operator+=(strlist&a, strlist b); string sql_list (string prefix,strlist v,string sep=",",string postfix=""); +const char *mugglepath(void); + class mgSQLStringImp { public: @@ -64,13 +64,8 @@ import() { bool path_within_tld() { - char path[5000]; - if (!getcwd(path,4999)) { - std::cout << "Path too long" << std::endl; - exit (1); - } + const char* path = mugglepath(); int tldlen = strlen(the_setup.ToplevelDir); - strcat(path,"/"); int pathlen = strlen(path); if (pathlen<tldlen) return false; |