settings: new configuration variable: generate_win32_compatible_filenames
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user