fs/Charset: GetFSCharset() returns "utf-8" by default
If fs_charset is empty, i.e. we're using the default "utf-8", GetFSCharset() should return exactly that instead of an empty std::string.
This commit is contained in:
parent
608a98c873
commit
7fec2b02d4
@ -56,8 +56,7 @@ db_save_internal(FILE *fp, const Directory *music_root)
|
|||||||
fprintf(fp, "%s\n", DIRECTORY_INFO_BEGIN);
|
fprintf(fp, "%s\n", DIRECTORY_INFO_BEGIN);
|
||||||
fprintf(fp, DB_FORMAT_PREFIX "%u\n", DB_FORMAT);
|
fprintf(fp, DB_FORMAT_PREFIX "%u\n", DB_FORMAT);
|
||||||
fprintf(fp, "%s%s\n", DIRECTORY_MPD_VERSION, VERSION);
|
fprintf(fp, "%s%s\n", DIRECTORY_MPD_VERSION, VERSION);
|
||||||
fprintf(fp, "%s%s\n", DIRECTORY_FS_CHARSET,
|
fprintf(fp, "%s%s\n", DIRECTORY_FS_CHARSET, GetFSCharset());
|
||||||
GetFSCharset().c_str());
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
|
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
|
||||||
if (!ignore_tag_items[i])
|
if (!ignore_tag_items[i])
|
||||||
@ -110,14 +109,14 @@ db_load_internal(TextFile &file, Directory *music_root, Error &error)
|
|||||||
found_charset = true;
|
found_charset = true;
|
||||||
|
|
||||||
new_charset = line + sizeof(DIRECTORY_FS_CHARSET) - 1;
|
new_charset = line + sizeof(DIRECTORY_FS_CHARSET) - 1;
|
||||||
const std::string &old_charset = GetFSCharset();
|
const char *const old_charset = GetFSCharset();
|
||||||
if (!old_charset.empty()
|
if (*old_charset != 0
|
||||||
&& strcmp(new_charset, old_charset.c_str())) {
|
&& strcmp(new_charset, old_charset) != 0) {
|
||||||
error.Format(db_domain,
|
error.Format(db_domain,
|
||||||
"Existing database has charset "
|
"Existing database has charset "
|
||||||
"\"%s\" instead of \"%s\"; "
|
"\"%s\" instead of \"%s\"; "
|
||||||
"discarding database file",
|
"discarding database file",
|
||||||
new_charset, old_charset.c_str());
|
new_charset, old_charset);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (g_str_has_prefix(line, DB_TAG_PREFIX)) {
|
} else if (g_str_has_prefix(line, DB_TAG_PREFIX)) {
|
||||||
|
@ -70,10 +70,10 @@ SetFSCharset(const char *charset)
|
|||||||
"SetFSCharset: fs charset is: %s", fs_charset.c_str());
|
"SetFSCharset: fs charset is: %s", fs_charset.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &
|
const char *
|
||||||
GetFSCharset()
|
GetFSCharset()
|
||||||
{
|
{
|
||||||
return fs_charset;
|
return fs_charset.empty() ? "utf-8" : fs_charset.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
* Gets file system character set name.
|
* Gets file system character set name.
|
||||||
*/
|
*/
|
||||||
gcc_const
|
gcc_const
|
||||||
const std::string &
|
const char *
|
||||||
GetFSCharset();
|
GetFSCharset();
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user