suport for renaming directories in tag editor
This commit is contained in:
@@ -703,7 +703,7 @@ string GetInfo(Song &s)
|
||||
{
|
||||
string result;
|
||||
# ifdef HAVE_TAGLIB_H
|
||||
string path_to_file = Config.mpd_music_dir + "/" + s.GetFile();
|
||||
string path_to_file = Config.mpd_music_dir + s.GetFile();
|
||||
TagLib::FileRef f(path_to_file.c_str());
|
||||
if (!f.isNull())
|
||||
s.SetComment(f.tag()->comment().to8Bit(UNICODE));
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
mEditorTagTypes->Display(redraw_screen); \
|
||||
mvvline(main_start_y, lib_songs_start_x-1, 0, main_height); \
|
||||
mEditorTags->Display(redraw_screen)
|
||||
|
||||
#define HAVE_TAGLIB_H
|
||||
ncmpcpp_config Config;
|
||||
ncmpcpp_keys Key;
|
||||
|
||||
@@ -2206,7 +2206,7 @@ int main(int argc, char *argv[])
|
||||
Mpd->CommitSearch(list);
|
||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
string path = Config.mpd_music_dir + "/" + (*it)->GetFile();
|
||||
string path = Config.mpd_music_dir + (*it)->GetFile();
|
||||
TagLib::FileRef f(path.c_str());
|
||||
if (f.isNull())
|
||||
{
|
||||
@@ -2239,7 +2239,7 @@ int main(int argc, char *argv[])
|
||||
Mpd->CommitSearch(list);
|
||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
{
|
||||
string path = Config.mpd_music_dir + "/" + (*it)->GetFile();
|
||||
string path = Config.mpd_music_dir + (*it)->GetFile();
|
||||
TagLib::FileRef f(path.c_str());
|
||||
if (f.isNull())
|
||||
{
|
||||
@@ -2291,7 +2291,26 @@ int main(int argc, char *argv[])
|
||||
current_screen = csTagEditor;
|
||||
}
|
||||
else
|
||||
ShowMessage("Cannot read file '" + Config.mpd_music_dir + "/" + edited_song.GetFile() + "'!");
|
||||
ShowMessage("Cannot read file '" + Config.mpd_music_dir + edited_song.GetFile() + "'!");
|
||||
}
|
||||
else if (wCurrent == mEditorDirs)
|
||||
{
|
||||
LOCK_STATUSBAR;
|
||||
wFooter->WriteXY(0, Config.statusbar_visibility, "Directory: ", 1);
|
||||
string new_dir = wFooter->GetString(mEditorDirs->Current().first);
|
||||
UNLOCK_STATUSBAR;
|
||||
if (!new_dir.empty() && new_dir != mEditorDirs->Current().first)
|
||||
{
|
||||
string old_dir = Config.mpd_music_dir + mEditorDirs->Current().second;
|
||||
new_dir = Config.mpd_music_dir + editor_browsed_dir + "/" + new_dir;
|
||||
if (rename(old_dir.c_str(), new_dir.c_str()) == 0)
|
||||
{
|
||||
ShowMessage("'" + mEditorDirs->Current().first + "' renamed to '" + new_dir);
|
||||
Mpd->UpdateDirectory(editor_browsed_dir);
|
||||
}
|
||||
else
|
||||
ShowMessage("Cannot rename '" + old_dir + "' to '" + new_dir + "'!");
|
||||
}
|
||||
}
|
||||
else
|
||||
# endif // HAVE_TAGLIB_H
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
# define UNICODE 0
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <clocale>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -148,7 +148,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
|
||||
void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
{
|
||||
conf.mpd_music_dir = "/var/lib/mpd/music";
|
||||
conf.mpd_music_dir = "/var/lib/mpd/music/";
|
||||
conf.song_list_format = "{[.green](%l)[/green] }{%a - }{%t}|{[.white]%f[/white]}";
|
||||
conf.song_columns_list_format = "(8)[green]{l} (28)[cyan]{a} (28){b} (50)[red]{t}";
|
||||
conf.song_status_format = "{(%l) }{%a - }{%t}|{%f}";
|
||||
@@ -435,7 +435,7 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
||||
if (it->find("mpd_music_dir") != string::npos)
|
||||
{
|
||||
if (!v.empty())
|
||||
conf.mpd_music_dir = v;
|
||||
conf.mpd_music_dir = v + "/";
|
||||
}
|
||||
else if (it->find("mpd_connection_timeout") != string::npos)
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ string DisplayTag(const Song &s, void *data)
|
||||
|
||||
bool GetSongTags(Song &s)
|
||||
{
|
||||
string path_to_file = Config.mpd_music_dir + "/" + s.GetFile();
|
||||
string path_to_file = Config.mpd_music_dir + s.GetFile();
|
||||
|
||||
TagLib::FileRef f(path_to_file.c_str());
|
||||
if (f.isNull())
|
||||
@@ -114,7 +114,7 @@ bool GetSongTags(Song &s)
|
||||
|
||||
bool WriteTags(Song &s)
|
||||
{
|
||||
string path_to_file = Config.mpd_music_dir + "/" + s.GetFile();
|
||||
string path_to_file = Config.mpd_music_dir + s.GetFile();
|
||||
TagLib::FileRef f(path_to_file.c_str());
|
||||
if (!f.isNull())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user