settings: new configuration variable: generate_win32_compatible_filenames

master
Andrzej Rybczak 13 years ago
parent a6c843569a
commit 133554bfea
  1. 2
      doc/config
  2. 3
      doc/ncmpcpp.1
  3. 2
      src/lastfm.cpp
  4. 2
      src/lyrics.cpp
  5. 5
      src/settings.cpp
  6. 1
      src/settings.h
  7. 2
      src/tag_editor.cpp
  8. 4
      src/utility/string.cpp
  9. 2
      src/utility/string.h

@ -345,6 +345,8 @@
#
#store_lyrics_in_song_dir = "no"
#
#generate_win32_compatible_filenames = "yes"
#
##
## Note: If you set this variable, ncmpcpp will try to
## get info from last.fm in language you set and if it

@ -258,6 +258,9 @@ If enabled, each time song changes lyrics fetcher will be automatically run in b
.B store_lyrics_in_song_dir = yes/no
If enabled, lyrics will be saved in song's directory, otherwise in ~/.lyrics. Note that it needs properly set mpd_music_dir.
.TP
.B generate_win32_compatible_filenames = yes/no
If set to yes, filenames generated by ncmpcpp (with tag editor, for lyrics, artists etc.) will not contain the following characters: /\?*:|"<> - otherwise only slash (/) will not be used.
.TP
.B lastfm_preferred_language = ISO 639 alpha-2 language code
If set, ncmpcpp will try to get info from last.fm in language you set and if it fails, it will fall back to english. Otherwise it will use english the first time.
.TP

@ -115,7 +115,7 @@ void Lastfm::Load()
std::string artist = itsArgs.find("artist")->second;
std::string file = boost::locale::to_lower(artist + ".txt");
removeInvalidCharsFromFilename(file);
removeInvalidCharsFromFilename(file, Config.generate_win32_compatible_filenames);
itsFilename = itsFolder + "/" + file;

@ -290,7 +290,7 @@ std::string Lyrics::GenerateFilename(const MPD::Song &s)
file += " - ";
file += s.getTitle();
file += ".txt";
removeInvalidCharsFromFilename(file);
removeInvalidCharsFromFilename(file, Config.generate_win32_compatible_filenames);
filename = Config.lyrics_directory;
filename += "/";
filename += file;

@ -215,6 +215,7 @@ void Configuration::SetDefaults()
tag_editor_extended_numeration = false;
discard_colors_if_item_is_selected = true;
store_lyrics_in_song_dir = false;
generate_win32_compatible_filenames = true;
ask_for_locked_screen_width_part = true;
progressbar_boldness = true;
set_window_title = true;
@ -764,6 +765,10 @@ void Configuration::Read()
else
store_lyrics_in_song_dir = v == "yes";
}
else if (name == "generate_win32_compatible_filenames")
{
generate_win32_compatible_filenames = v == "yes";
}
else if (name == "enable_window_title")
{
set_window_title = v == "yes";

@ -181,6 +181,7 @@ struct Configuration
bool tag_editor_extended_numeration;
bool discard_colors_if_item_is_selected;
bool store_lyrics_in_song_dir;
bool generate_win32_compatible_filenames;
bool ask_for_locked_screen_width_part;
bool progressbar_boldness;

@ -1099,7 +1099,7 @@ MPD::MutableSong::SetFunction IntoSetFunction(char c)
std::string GenerateFilename(const MPD::MutableSong &s, const std::string &pattern)
{
std::string result = s.toString(pattern, Config.tags_separator);
removeInvalidCharsFromFilename(result);
removeInvalidCharsFromFilename(result, Config.generate_win32_compatible_filenames);
return result;
}

@ -91,9 +91,9 @@ std::string getEnclosedString(const std::string &s, char a, char b, size_t *pos)
return result;
}
void removeInvalidCharsFromFilename(std::string &filename)
void removeInvalidCharsFromFilename(std::string &filename, bool win32_compatible)
{
const char *unallowed_chars = "\"*/:<>?\\|";
const char *unallowed_chars = win32_compatible ? "\"*/:<>?\\|" : "/";
for (const char *c = unallowed_chars; *c; ++c)
{
for (size_t i = 0; i < filename.length(); ++i)

@ -39,6 +39,6 @@ std::string getSharedDirectory(const std::string &dir1, const std::string &dir2)
std::string getEnclosedString(const std::string &s, char a, char b, size_t *pos);
void removeInvalidCharsFromFilename(std::string &filename);
void removeInvalidCharsFromFilename(std::string &filename, bool win32_compatible);
#endif // NCMPCPP_UTILITY_STRING_H

Loading…
Cancel
Save