use mkdir() instead of system() + a few clean-ups

This commit is contained in:
unK
2008-09-04 01:03:29 +02:00
parent d7b635e276
commit c2225172fb
5 changed files with 15 additions and 15 deletions

View File

@@ -85,7 +85,7 @@
## - color is optional (if it's not present, default window color will be used) ## - color is optional (if it's not present, default window color will be used)
## ##
# #
#song_columns_list_format = "(8)[green]{l} (28)[cyan]{a} (28)[yellow]{b} (50)[red]{t}" #song_columns_list_format = "(8)[green]{l} (28)[cyan]{a} (28){b} (50)[red]{t}"
# #
##### various settings ##### ##### various settings #####
# #

View File

@@ -19,9 +19,9 @@
***************************************************************************/ ***************************************************************************/
#include "lyrics.h" #include "lyrics.h"
#include <fcntl.h>
const string lyrics_folder = home_folder + "/" + ".lyrics"; const string lyrics_folder = home_folder + "/" + ".lyrics";
const string mkdir_command = "mkdir " + lyrics_folder + " &>/dev/null";
size_t write_data(char *buffer, size_t size, size_t nmemb, string data) size_t write_data(char *buffer, size_t size, size_t nmemb, string data)
{ {
@@ -38,7 +38,7 @@ string GetLyrics(string artist, string song)
{ {
const string filename = artist + " - " + song + ".txt"; const string filename = artist + " - " + song + ".txt";
const string fullpath = lyrics_folder + "/" + filename; const string fullpath = lyrics_folder + "/" + filename;
system(mkdir_command.c_str()); mkdir(lyrics_folder.c_str(), 0755);
string result; string result;
std::ifstream input(fullpath.c_str()); std::ifstream input(fullpath.c_str());

View File

@@ -309,7 +309,7 @@ string Menu<T>::GetCurrentOption() const
{ {
try try
{ {
return OmitBBCodes(DisplayOption(itsOptions.at(itsHighlight)->item)); return DisplayOption(itsOptions.at(itsHighlight)->item);
} }
catch (std::out_of_range) catch (std::out_of_range)
{ {
@@ -322,7 +322,7 @@ string Menu<T>::GetOption(int i) const
{ {
try try
{ {
return OmitBBCodes(DisplayOption(itsOptions.at(i-1)->item)); return DisplayOption(itsOptions.at(i-1)->item);
} }
catch (std::out_of_range) catch (std::out_of_range)
{ {

View File

@@ -814,7 +814,7 @@ int main(int argc, char *argv[])
if (id >= 0) if (id >= 0)
{ {
Mpd->PlayID(id); Mpd->PlayID(id);
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + DisplaySong(s, &Config.song_status_format));
} }
mBrowser->Refresh(); mBrowser->Refresh();
break; break;
@@ -1125,7 +1125,7 @@ int main(int argc, char *argv[])
if (id >= 0) if (id >= 0)
{ {
Mpd->PlayID(id); Mpd->PlayID(id);
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + DisplaySong(s, &Config.song_status_format));
} }
break; break;
} }
@@ -1185,7 +1185,7 @@ int main(int argc, char *argv[])
int id = Mpd->AddSong(s); int id = Mpd->AddSong(s);
if (id >= 0) if (id >= 0)
{ {
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + DisplaySong(s, &Config.song_status_format));
if (Keypressed(input, Key.Enter)) if (Keypressed(input, Key.Enter))
Mpd->PlayID(id); Mpd->PlayID(id);
} }
@@ -1229,7 +1229,7 @@ int main(int argc, char *argv[])
int id = Mpd->AddSong(s); int id = Mpd->AddSong(s);
if (id >= 0) if (id >= 0)
{ {
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + DisplaySong(s, &Config.song_status_format));
if (Keypressed(input, Key.Enter)) if (Keypressed(input, Key.Enter))
Mpd->PlayID(id); Mpd->PlayID(id);
} }
@@ -1286,7 +1286,7 @@ int main(int argc, char *argv[])
{ {
Song &s = *item.song; Song &s = *item.song;
if (Mpd->AddSong(s) != -1) if (Mpd->AddSong(s) != -1)
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + DisplaySong(s, &Config.song_status_format));
break; break;
} }
case itPlaylist: case itPlaylist:
@@ -1316,7 +1316,7 @@ int main(int argc, char *argv[])
Song &s = *vSearched[id]; Song &s = *vSearched[id];
if (Mpd->AddSong(s) != -1) if (Mpd->AddSong(s) != -1)
ShowMessage("Added to playlist: " + OmitBBCodes(DisplaySong(s))); ShowMessage("Added to playlist: " + DisplaySong(s, &Config.song_status_format));
mSearcher->Go(wDown); mSearcher->Go(wDown);
} }
else if (current_screen == csLibrary) else if (current_screen == csLibrary)
@@ -1833,7 +1833,7 @@ int main(int argc, char *argv[])
if (s->GetDirectory() == EMPTY_TAG) // for streams if (s->GetDirectory() == EMPTY_TAG) // for streams
continue; continue;
string option = OmitBBCodes(DisplaySong(*s)); string option = DisplaySong(*s);
GetDirectory(s->GetDirectory()); GetDirectory(s->GetDirectory());
for (int i = 1; i <= mBrowser->Size(); i++) for (int i = 1; i <= mBrowser->Size(); i++)
{ {
@@ -2127,7 +2127,7 @@ int main(int argc, char *argv[])
for (int i = (wCurrent == mBrowser ? search_engine_static_option : 1); i <= mCurrent->Size(); i++) for (int i = (wCurrent == mBrowser ? search_engine_static_option : 1); i <= mCurrent->Size(); i++)
{ {
string name = mCurrent->GetOption(i); string name = OmitBBCodes(mCurrent->GetOption(i));
transform(name.begin(), name.end(), name.begin(), tolower); transform(name.begin(), name.end(), name.begin(), tolower);
if (name.find(findme) != string::npos && !mCurrent->IsStatic(i)) if (name.find(findme) != string::npos && !mCurrent->IsStatic(i))
{ {

View File

@@ -312,7 +312,7 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
tracklength = " [" + ShowTime(elapsed) + "/" + s.GetLength() + "]"; tracklength = " [" + ShowTime(elapsed) + "/" + s.GetLength() + "]";
else else
tracklength = " [" + ShowTime(elapsed) + "]"; tracklength = " [" + ShowTime(elapsed) + "]";
ncmpcpp_string_t playing_song = TO_WSTRING(OmitBBCodes(DisplaySong(s, &Config.song_status_format))); ncmpcpp_string_t playing_song = TO_WSTRING(DisplaySong(s, &Config.song_status_format));
int max_length_without_scroll = wFooter->GetWidth()-player_state.length()-tracklength.length(); int max_length_without_scroll = wFooter->GetWidth()-player_state.length()-tracklength.length();
@@ -334,7 +334,7 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
playing_song_scroll_begin = 0; playing_song_scroll_begin = 0;
} }
else else
wFooter->WriteXY(player_state.length(), 1, OmitBBCodes(DisplaySong(s, &Config.song_status_format)), 1); wFooter->WriteXY(player_state.length(), 1, DisplaySong(s, &Config.song_status_format), 1);
wFooter->Bold(1); wFooter->Bold(1);
wFooter->WriteXY(wFooter->GetWidth()-tracklength.length(), 1, tracklength); wFooter->WriteXY(wFooter->GetWidth()-tracklength.length(), 1, tracklength);