mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-14 13:21:13 +00:00
Merge pull request #565 from clangen/clangen/accented-chars
Various bug fixes, including some related to accented character search
This commit is contained in:
commit
e691db7f47
@ -1,8 +1,12 @@
|
||||
0.99.1
|
||||
|
||||
* fixed OpenBSD compile
|
||||
* fixed indexer issues related to last modified file time; some code was
|
||||
using 32-bit integers for timestamp comparison, leading to incorrect
|
||||
re-indexing
|
||||
* fixed issues when searching for metadata with accented characters
|
||||
* fixed issue with FfmpegDecoder that was preventing .wma files (and possibly
|
||||
other formats) from playing properly.
|
||||
* fixed OpenBSD compile
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -65,188 +65,291 @@ english characters to make it easier to search. */
|
||||
typedef UINT8_TYPE u8; /* 1-byte unsigned integer */
|
||||
typedef UINT32_TYPE u32; /* 4-byte unsigned integer */
|
||||
|
||||
/* mappings from ASCII characters to a list of their respective accented
|
||||
characters. both case sensitive and insensitive versions are supplied here. */
|
||||
static std::unordered_map<u32, const char*> charToAccentsInsensitive = {
|
||||
{ (u32)'a', u8"AaàáâãäåāăąÀÁÂÃÄÅĀĂĄ" },
|
||||
{ (u32)'c', u8"CcçćĉċčÇĆĈĊČ" },
|
||||
{ (u32)'d', u8"DdďđĎĐ" },
|
||||
{ (u32)'e', u8"EeèéêëēĕėęěÈÉÊËĒĔĖĘĚ" },
|
||||
{ (u32)'g', u8"GgĝğġģĜĞĠĢ" },
|
||||
{ (u32)'h', u8"HhĥħĤĦ" },
|
||||
{ (u32)'i', u8"IiìíîïĩīĭįıÌÍÎÏĨĪĬĮİ" },
|
||||
{ (u32)'j', u8"JjĵĴ" },
|
||||
{ (u32)'k', u8"KkķĸĶ" },
|
||||
{ (u32)'l', u8"LlĺļľŀłĹĻĽĿŁ" },
|
||||
{ (u32)'n', u8"NnñńņňŊÑŃŅŇʼnŋ" },
|
||||
{ (u32)'o', u8"OoòóôõöùúûüōŏőÒÓÔÕÖŌŎŐ" },
|
||||
{ (u32)'r', u8"RrŕŗřŔŖŘ" },
|
||||
{ (u32)'s', u8"Ssśŝşšſß" },
|
||||
{ (u32)'t', u8"TtţťŧŢŤŦ" },
|
||||
{ (u32)'u', u8"UuũūŭůűųÙÚÛÜŨŪŬŮŰŲ" },
|
||||
{ (u32)'w', u8"WwŵŴ" },
|
||||
{ (u32)'y', u8"YyýÿŷÝŶŸ" },
|
||||
{ (u32)'z', u8"ZzŹŻŽ" },
|
||||
};
|
||||
|
||||
static std::unordered_map<u32, const char*> charToAccentsSensitive = {
|
||||
{ (u32)'A', u8"AÀÁÂÃÄÅĀĂĄ" },
|
||||
{ (u32)'C', u8"CÇĆĈĊČ" },
|
||||
{ (u32)'D', u8"DĎĐ" },
|
||||
{ (u32)'E', u8"EÈÉÊËĒĔĖĘĚ" },
|
||||
{ (u32)'G', u8"GĜĞĠĢ" },
|
||||
{ (u32)'H', u8"HĤĦ" },
|
||||
{ (u32)'I', u8"IÌÍÎÏĨĪĬĮİ" },
|
||||
{ (u32)'J', u8"JĴ" },
|
||||
{ (u32)'K', u8"KĶ" },
|
||||
{ (u32)'L', u8"LĹĻĽĿŁ" },
|
||||
{ (u32)'N', u8"NÑŃŅŇʼnŋ" },
|
||||
{ (u32)'O', u8"OÒÓÔÕÖŌŎŐ" },
|
||||
{ (u32)'R', u8"RŔŖŘ" },
|
||||
{ (u32)'S', u8"Sß" },
|
||||
{ (u32)'T', u8"TŢŤŦ" },
|
||||
{ (u32)'U', u8"UÙÚÛÜŨŪŬŮŰŲ" },
|
||||
{ (u32)'W', u8"WŴ" },
|
||||
{ (u32)'Y', u8"YÝŶŸ" },
|
||||
{ (u32)'Z', u8"ZŹŻŽ" },
|
||||
{ (u32)'a', u8"aàáâãäåāăą" },
|
||||
{ (u32)'c', u8"cçćĉċč" },
|
||||
{ (u32)'d', u8"dďđ" },
|
||||
{ (u32)'e', u8"eèéêëēĕėęě" },
|
||||
{ (u32)'g', u8"gĝğġģ" },
|
||||
{ (u32)'h', u8"hĥħ" },
|
||||
{ (u32)'i', u8"iìíîïĩīĭįı" },
|
||||
{ (u32)'j', u8"jĵ" },
|
||||
{ (u32)'k', u8"kķĸ" },
|
||||
{ (u32)'l', u8"lĺļľŀł" },
|
||||
{ (u32)'n', u8"nñńņňŊ" },
|
||||
{ (u32)'o', u8"oòóôõöùúûüōŏő" },
|
||||
{ (u32)'r', u8"rŕŗř" },
|
||||
{ (u32)'s', u8"sśŝşšſ" },
|
||||
{ (u32)'t', u8"tţťŧ" },
|
||||
{ (u32)'u', u8"uũūŭůűų" },
|
||||
{ (u32)'w', u8"wŵ" },
|
||||
{ (u32)'y', u8"yýÿŷ" },
|
||||
};
|
||||
|
||||
/*
|
||||
** Mapping from accented UTF8 sequence to a regular english char
|
||||
*/
|
||||
static std::unordered_map<u32, u32> accentToChar = {
|
||||
{ (u32)192 /* À */ , (u32)'A' },
|
||||
{ (u32)193 /* Á */ , (u32)'A' },
|
||||
{ (u32)194 /* Â */ , (u32)'A' },
|
||||
{ (u32)195 /* Ã */ , (u32)'A' },
|
||||
{ (u32)196 /* Ä */ , (u32)'A' },
|
||||
{ (u32)197 /* Å */ , (u32)'A' },
|
||||
{ (u32)199 /* Ç */ , (u32)'C' },
|
||||
{ (u32)200 /* È */ , (u32)'E' },
|
||||
{ (u32)201 /* É */ , (u32)'E' },
|
||||
{ (u32)202 /* Ê */ , (u32)'E' },
|
||||
{ (u32)203 /* Ë */ , (u32)'E' },
|
||||
{ (u32)204 /* Ì */ , (u32)'I' },
|
||||
{ (u32)205 /* Í */ , (u32)'I' },
|
||||
{ (u32)206 /* Î */ , (u32)'I' },
|
||||
{ (u32)207 /* Ï */ , (u32)'I' },
|
||||
{ (u32)209 /* Ñ */ , (u32)'N' },
|
||||
{ (u32)210 /* Ò */ , (u32)'O' },
|
||||
{ (u32)211 /* Ó */ , (u32)'O' },
|
||||
{ (u32)212 /* Ô */ , (u32)'O' },
|
||||
{ (u32)213 /* Õ */ , (u32)'O' },
|
||||
{ (u32)214 /* Ö */ , (u32)'O' },
|
||||
{ (u32)217 /* Ù */ , (u32)'U' },
|
||||
{ (u32)218 /* Ú */ , (u32)'U' },
|
||||
{ (u32)219 /* Û */ , (u32)'U' },
|
||||
{ (u32)220 /* Ü */ , (u32)'U' },
|
||||
{ (u32)221 /* Ý */ , (u32)'Y' },
|
||||
{ (u32)223 /* ß */ , (u32)'s' },
|
||||
{ (u32)224 /* à */ , (u32)'a' },
|
||||
{ (u32)225 /* á */ , (u32)'a' },
|
||||
{ (u32)226 /* â */ , (u32)'a' },
|
||||
{ (u32)227 /* ã */ , (u32)'a' },
|
||||
{ (u32)228 /* ä */ , (u32)'a' },
|
||||
{ (u32)229 /* å */ , (u32)'a' },
|
||||
{ (u32)231 /* ç */ , (u32)'c' },
|
||||
{ (u32)232 /* è */ , (u32)'e' },
|
||||
{ (u32)233 /* é */ , (u32)'e' },
|
||||
{ (u32)234 /* ê */ , (u32)'e' },
|
||||
{ (u32)235 /* ë */ , (u32)'e' },
|
||||
{ (u32)236 /* ì */ , (u32)'i' },
|
||||
{ (u32)237 /* í */ , (u32)'i' },
|
||||
{ (u32)238 /* î */ , (u32)'i' },
|
||||
{ (u32)239 /* ï */ , (u32)'i' },
|
||||
{ (u32)241 /* ñ */ , (u32)'n' },
|
||||
{ (u32)242 /* ò */ , (u32)'o' },
|
||||
{ (u32)243 /* ó */ , (u32)'o' },
|
||||
{ (u32)244 /* ô */ , (u32)'o' },
|
||||
{ (u32)245 /* õ */ , (u32)'o' },
|
||||
{ (u32)246 /* ö */ , (u32)'o' },
|
||||
{ (u32)249 /* ù */ , (u32)'u' },
|
||||
{ (u32)250 /* ú */ , (u32)'u' },
|
||||
{ (u32)251 /* û */ , (u32)'u' },
|
||||
{ (u32)252 /* ü */ , (u32)'u' },
|
||||
{ (u32)253 /* ý */ , (u32)'y' },
|
||||
{ (u32)255 /* ÿ */ , (u32)'y' },
|
||||
{ (u32)256 /* Ā */ , (u32)'A' },
|
||||
{ (u32)257 /* ā */ , (u32)'a' },
|
||||
{ (u32)258 /* Ă */ , (u32)'A' },
|
||||
{ (u32)259 /* ă */ , (u32)'a' },
|
||||
{ (u32)260 /* Ą */ , (u32)'A' },
|
||||
{ (u32)261 /* ą */ , (u32)'a' },
|
||||
{ (u32)262 /* Ć */ , (u32)'C' },
|
||||
{ (u32)263 /* ć */ , (u32)'c' },
|
||||
{ (u32)264 /* Ĉ */ , (u32)'C' },
|
||||
{ (u32)265 /* ĉ */ , (u32)'c' },
|
||||
{ (u32)266 /* Ċ */ , (u32)'C' },
|
||||
{ (u32)267 /* ċ */ , (u32)'c' },
|
||||
{ (u32)268 /* Č */ , (u32)'C' },
|
||||
{ (u32)269 /* č */ , (u32)'c' },
|
||||
{ (u32)270 /* Ď */ , (u32)'D' },
|
||||
{ (u32)271 /* ď */ , (u32)'d' },
|
||||
{ (u32)272 /* Đ */ , (u32)'D' },
|
||||
{ (u32)273 /* đ */ , (u32)'d' },
|
||||
{ (u32)274 /* Ē */ , (u32)'E' },
|
||||
{ (u32)275 /* ē */ , (u32)'e' },
|
||||
{ (u32)276 /* Ĕ */ , (u32)'E' },
|
||||
{ (u32)277 /* ĕ */ , (u32)'e' },
|
||||
{ (u32)278 /* Ė */ , (u32)'E' },
|
||||
{ (u32)279 /* ė */ , (u32)'e' },
|
||||
{ (u32)280 /* Ę */ , (u32)'E' },
|
||||
{ (u32)281 /* ę */ , (u32)'e' },
|
||||
{ (u32)282 /* Ě */ , (u32)'E' },
|
||||
{ (u32)283 /* ě */ , (u32)'e' },
|
||||
{ (u32)284 /* Ĝ */ , (u32)'G' },
|
||||
{ (u32)285 /* ĝ */ , (u32)'g' },
|
||||
{ (u32)286 /* Ğ */ , (u32)'G' },
|
||||
{ (u32)287 /* ğ */ , (u32)'g' },
|
||||
{ (u32)288 /* Ġ */ , (u32)'G' },
|
||||
{ (u32)289 /* ġ */ , (u32)'g' },
|
||||
{ (u32)290 /* Ģ */ , (u32)'G' },
|
||||
{ (u32)291 /* ģ */ , (u32)'g' },
|
||||
{ (u32)292 /* Ĥ */ , (u32)'H' },
|
||||
{ (u32)293 /* ĥ */ , (u32)'h' },
|
||||
{ (u32)294 /* Ħ */ , (u32)'H' },
|
||||
{ (u32)295 /* ħ */ , (u32)'h' },
|
||||
{ (u32)296 /* Ĩ */ , (u32)'I' },
|
||||
{ (u32)297 /* ĩ */ , (u32)'i' },
|
||||
{ (u32)298 /* Ī */ , (u32)'I' },
|
||||
{ (u32)299 /* ī */ , (u32)'i' },
|
||||
{ (u32)300 /* Ĭ */ , (u32)'I' },
|
||||
{ (u32)301 /* ĭ */ , (u32)'i' },
|
||||
{ (u32)302 /* Į */ , (u32)'I' },
|
||||
{ (u32)303 /* į */ , (u32)'i' },
|
||||
{ (u32)304 /* İ */ , (u32)'I' },
|
||||
{ (u32)305 /* ı */ , (u32)'i' },
|
||||
{ (u32)308 /* Ĵ */ , (u32)'J' },
|
||||
{ (u32)309 /* ĵ */ , (u32)'j' },
|
||||
{ (u32)310 /* Ķ */ , (u32)'K' },
|
||||
{ (u32)311 /* ķ */ , (u32)'k' },
|
||||
{ (u32)312 /* ĸ */ , (u32)'k' },
|
||||
{ (u32)313 /* Ĺ */ , (u32)'L' },
|
||||
{ (u32)314 /* ĺ */ , (u32)'l' },
|
||||
{ (u32)315 /* Ļ */ , (u32)'L' },
|
||||
{ (u32)316 /* ļ */ , (u32)'l' },
|
||||
{ (u32)317 /* Ľ */ , (u32)'L' },
|
||||
{ (u32)318 /* ľ */ , (u32)'l' },
|
||||
{ (u32)319 /* Ŀ */ , (u32)'L' },
|
||||
{ (u32)320 /* ŀ */ , (u32)'l' },
|
||||
{ (u32)321 /* Ł */ , (u32)'L' },
|
||||
{ (u32)322 /* ł */ , (u32)'l' },
|
||||
{ (u32)323 /* Ń */ , (u32)'N' },
|
||||
{ (u32)324 /* ń */ , (u32)'n' },
|
||||
{ (u32)325 /* Ņ */ , (u32)'N' },
|
||||
{ (u32)326 /* ņ */ , (u32)'n' },
|
||||
{ (u32)327 /* Ň */ , (u32)'N' },
|
||||
{ (u32)328 /* ň */ , (u32)'n' },
|
||||
{ (u32)329 /* ʼn */ , (u32)'N' },
|
||||
{ (u32)330 /* Ŋ */ , (u32)'n' },
|
||||
{ (u32)331 /* ŋ */ , (u32)'N' },
|
||||
{ (u32)332 /* Ō */ , (u32)'O' },
|
||||
{ (u32)333 /* ō */ , (u32)'o' },
|
||||
{ (u32)334 /* Ŏ */ , (u32)'O' },
|
||||
{ (u32)335 /* ŏ */ , (u32)'o' },
|
||||
{ (u32)336 /* Ő */ , (u32)'O' },
|
||||
{ (u32)337 /* ő */ , (u32)'o' },
|
||||
{ (u32)340 /* Ŕ */ , (u32)'R' },
|
||||
{ (u32)341 /* ŕ */ , (u32)'r' },
|
||||
{ (u32)342 /* Ŗ */ , (u32)'R' },
|
||||
{ (u32)343 /* ŗ */ , (u32)'r' },
|
||||
{ (u32)344 /* Ř */ , (u32)'R' },
|
||||
{ (u32)345 /* ř */ , (u32)'r' },
|
||||
{ (u32)346 /* Ś */ , (u32)'S' },
|
||||
{ (u32)347 /* ś */ , (u32)'s' },
|
||||
{ (u32)348 /* Ŝ */ , (u32)'S' },
|
||||
{ (u32)349 /* ŝ */ , (u32)'s' },
|
||||
{ (u32)350 /* Ş */ , (u32)'S' },
|
||||
{ (u32)351 /* ş */ , (u32)'s' },
|
||||
{ (u32)352 /* Š */ , (u32)'S' },
|
||||
{ (u32)353 /* š */ , (u32)'s' },
|
||||
{ (u32)354 /* Ţ */ , (u32)'T' },
|
||||
{ (u32)355 /* ţ */ , (u32)'t' },
|
||||
{ (u32)356 /* Ť */ , (u32)'T' },
|
||||
{ (u32)357 /* ť */ , (u32)'t' },
|
||||
{ (u32)358 /* Ŧ */ , (u32)'T' },
|
||||
{ (u32)359 /* ŧ */ , (u32)'t' },
|
||||
{ (u32)360 /* Ũ */ , (u32)'U' },
|
||||
{ (u32)361 /* ũ */ , (u32)'u' },
|
||||
{ (u32)362 /* Ū */ , (u32)'U' },
|
||||
{ (u32)363 /* ū */ , (u32)'u' },
|
||||
{ (u32)364 /* Ŭ */ , (u32)'U' },
|
||||
{ (u32)365 /* ŭ */ , (u32)'u' },
|
||||
{ (u32)366 /* Ů */ , (u32)'U' },
|
||||
{ (u32)367 /* ů */ , (u32)'u' },
|
||||
{ (u32)368 /* Ű */ , (u32)'U' },
|
||||
{ (u32)369 /* ű */ , (u32)'u' },
|
||||
{ (u32)370 /* Ų */ , (u32)'U' },
|
||||
{ (u32)371 /* ų */ , (u32)'u' },
|
||||
{ (u32)372 /* Ŵ */ , (u32)'W' },
|
||||
{ (u32)373 /* ŵ */ , (u32)'w' },
|
||||
{ (u32)374 /* Ŷ */ , (u32)'Y' },
|
||||
{ (u32)375 /* ŷ */ , (u32)'y' },
|
||||
{ (u32)376 /* Ÿ */ , (u32)'Y' },
|
||||
{ (u32)377 /* Ź */ , (u32)'Z' },
|
||||
{ (u32)378 /* ź */ , (u32)'z' },
|
||||
{ (u32)379 /* Ż */ , (u32)'Z' },
|
||||
{ (u32)380 /* ż */ , (u32)'z' },
|
||||
{ (u32)381 /* Ž */ , (u32)'Z' },
|
||||
{ (u32)382 /* ž */ , (u32)'z' },
|
||||
{ (u32)383 /* ſ */ , (u32)'s' },
|
||||
/* A */
|
||||
{ (u32)0xc0 /* À */ , (u32)'A' },
|
||||
{ (u32)0xc1 /* Á */ , (u32)'A' },
|
||||
{ (u32)0xc2 /* Â */ , (u32)'A' },
|
||||
{ (u32)0xc3 /* Ã */ , (u32)'A' },
|
||||
{ (u32)0xc4 /* Ä */ , (u32)'A' },
|
||||
{ (u32)0xc5 /* Å */ , (u32)'A' },
|
||||
{ (u32)0x100 /* Ā */ , (u32)'A' },
|
||||
{ (u32)0x102 /* Ă */ , (u32)'A' },
|
||||
{ (u32)0x104 /* Ą */ , (u32)'A' },
|
||||
/* C */
|
||||
{ (u32)0xc7 /* Ç */ , (u32)'C' },
|
||||
{ (u32)0x106 /* Ć */ , (u32)'C' },
|
||||
{ (u32)0x108 /* Ĉ */ , (u32)'C' },
|
||||
{ (u32)0x10a /* Ċ */ , (u32)'C' },
|
||||
{ (u32)0x10c /* Č */ , (u32)'C' },
|
||||
/* D */
|
||||
{ (u32)0x10e /* Ď */ , (u32)'D' },
|
||||
{ (u32)0x110 /* Đ */ , (u32)'D' },
|
||||
/* E */
|
||||
{ (u32)0xc8 /* È */ , (u32)'E' },
|
||||
{ (u32)0xc9 /* É */ , (u32)'E' },
|
||||
{ (u32)0xca /* Ê */ , (u32)'E' },
|
||||
{ (u32)0xcb /* Ë */ , (u32)'E' },
|
||||
{ (u32)0x112 /* Ē */ , (u32)'E' },
|
||||
{ (u32)0x114 /* Ĕ */ , (u32)'E' },
|
||||
{ (u32)0x116 /* Ė */ , (u32)'E' },
|
||||
{ (u32)0x118 /* Ę */ , (u32)'E' },
|
||||
{ (u32)0x11a /* Ě */ , (u32)'E' },
|
||||
/* G */
|
||||
{ (u32)0x11c /* Ĝ */ , (u32)'G' },
|
||||
{ (u32)0x11e /* Ğ */ , (u32)'G' },
|
||||
{ (u32)0x120 /* Ġ */ , (u32)'G' },
|
||||
{ (u32)0x122 /* Ģ */ , (u32)'G' },
|
||||
/* H */
|
||||
{ (u32)0x124 /* Ĥ */ , (u32)'H' },
|
||||
{ (u32)0x126 /* Ħ */ , (u32)'H' },
|
||||
/* I */
|
||||
{ (u32)0xcc /* Ì */ , (u32)'I' },
|
||||
{ (u32)0xcd /* Í */ , (u32)'I' },
|
||||
{ (u32)0xce /* Î */ , (u32)'I' },
|
||||
{ (u32)0xcf /* Ï */ , (u32)'I' },
|
||||
{ (u32)0x128 /* Ĩ */ , (u32)'I' },
|
||||
{ (u32)0x12a /* Ī */ , (u32)'I' },
|
||||
{ (u32)0x12c /* Ĭ */ , (u32)'I' },
|
||||
{ (u32)0x12e /* Į */ , (u32)'I' },
|
||||
{ (u32)0x130 /* İ */ , (u32)'I' },
|
||||
/* J */
|
||||
{ (u32)0x134 /* Ĵ */ , (u32)'J' },
|
||||
/* K */
|
||||
{ (u32)0x136 /* Ķ */ , (u32)'K' },
|
||||
/* L */
|
||||
{ (u32)0x139 /* Ĺ */ , (u32)'L' },
|
||||
{ (u32)0x13b /* Ļ */ , (u32)'L' },
|
||||
{ (u32)0x13d /* Ľ */ , (u32)'L' },
|
||||
{ (u32)0x13f /* Ŀ */ , (u32)'L' },
|
||||
{ (u32)0x141 /* Ł */ , (u32)'L' },
|
||||
/* N */
|
||||
{ (u32)0xd1 /* Ñ */ , (u32)'N' },
|
||||
{ (u32)0x143 /* Ń */ , (u32)'N' },
|
||||
{ (u32)0x145 /* Ņ */ , (u32)'N' },
|
||||
{ (u32)0x147 /* Ň */ , (u32)'N' },
|
||||
{ (u32)0x149 /* ʼn */ , (u32)'N' },
|
||||
{ (u32)0x14b /* ŋ */ , (u32)'N' },
|
||||
/* O */
|
||||
{ (u32)0xd2 /* Ò */ , (u32)'O' },
|
||||
{ (u32)0xd3 /* Ó */ , (u32)'O' },
|
||||
{ (u32)0xd4 /* Ô */ , (u32)'O' },
|
||||
{ (u32)0xd5 /* Õ */ , (u32)'O' },
|
||||
{ (u32)0xd6 /* Ö */ , (u32)'O' },
|
||||
{ (u32)0x14c /* Ō */ , (u32)'O' },
|
||||
{ (u32)0x14e /* Ŏ */ , (u32)'O' },
|
||||
{ (u32)0x150 /* Ő */ , (u32)'O' },
|
||||
/* R */
|
||||
{ (u32)0x154 /* Ŕ */ , (u32)'R' },
|
||||
{ (u32)0x156 /* Ŗ */ , (u32)'R' },
|
||||
{ (u32)0x158 /* Ř */ , (u32)'R' },
|
||||
/* S */
|
||||
{ (u32)0x15a /* Ś */ , (u32)'S' },
|
||||
{ (u32)0x15c /* Ŝ */ , (u32)'S' },
|
||||
{ (u32)0x15e /* Ş */ , (u32)'S' },
|
||||
{ (u32)0x160 /* Š */ , (u32)'S' },
|
||||
/* T */
|
||||
{ (u32)0x162 /* Ţ */ , (u32)'T' },
|
||||
{ (u32)0x164 /* Ť */ , (u32)'T' },
|
||||
{ (u32)0x166 /* Ŧ */ , (u32)'T' },
|
||||
/* U */
|
||||
{ (u32)0xd9 /* Ù */ , (u32)'U' },
|
||||
{ (u32)0xda /* Ú */ , (u32)'U' },
|
||||
{ (u32)0xdb /* Û */ , (u32)'U' },
|
||||
{ (u32)0xdc /* Ü */ , (u32)'U' },
|
||||
{ (u32)0x168 /* Ũ */ , (u32)'U' },
|
||||
{ (u32)0x16a /* Ū */ , (u32)'U' },
|
||||
{ (u32)0x16c /* Ŭ */ , (u32)'U' },
|
||||
{ (u32)0x16e /* Ů */ , (u32)'U' },
|
||||
{ (u32)0x170 /* Ű */ , (u32)'U' },
|
||||
{ (u32)0x172 /* Ų */ , (u32)'U' },
|
||||
/* W */
|
||||
{ (u32)0x174 /* Ŵ */ , (u32)'W' },
|
||||
/* Y */
|
||||
{ (u32)0xdd /* Ý */ , (u32)'Y' },
|
||||
{ (u32)0x176 /* Ŷ */ , (u32)'Y' },
|
||||
{ (u32)0x178 /* Ÿ */ , (u32)'Y' },
|
||||
/* S */
|
||||
{ (u32)0xdf /* ß */ , (u32)'s' },
|
||||
/* Z */
|
||||
{ (u32)0x179 /* Ź */ , (u32)'Z' },
|
||||
{ (u32)0x17b /* Ż */ , (u32)'Z' },
|
||||
{ (u32)0x17d /* Ž */ , (u32)'Z' },
|
||||
/* a */
|
||||
{ (u32)0xe0 /* à */ , (u32)'a' },
|
||||
{ (u32)0xe1 /* á */ , (u32)'a' },
|
||||
{ (u32)0xe2 /* â */ , (u32)'a' },
|
||||
{ (u32)0xe3 /* ã */ , (u32)'a' },
|
||||
{ (u32)0xe4 /* ä */ , (u32)'a' },
|
||||
{ (u32)0xe5 /* å */ , (u32)'a' },
|
||||
{ (u32)0x101 /* ā */ , (u32)'a' },
|
||||
{ (u32)0x103 /* ă */ , (u32)'a' },
|
||||
{ (u32)0x105 /* ą */ , (u32)'a' },
|
||||
/* c */
|
||||
{ (u32)0xe7 /* ç */ , (u32)'c' },
|
||||
{ (u32)0x107 /* ć */ , (u32)'c' },
|
||||
{ (u32)0x109 /* ĉ */ , (u32)'c' },
|
||||
{ (u32)0x10b /* ċ */ , (u32)'c' },
|
||||
{ (u32)0x10d /* č */ , (u32)'c' },
|
||||
/* d */
|
||||
{ (u32)0x10f /* ď */ , (u32)'d' },
|
||||
{ (u32)0x111 /* đ */ , (u32)'d' },
|
||||
/* e */
|
||||
{ (u32)0xe8 /* è */ , (u32)'e' },
|
||||
{ (u32)0xe9 /* é */ , (u32)'e' },
|
||||
{ (u32)0xea /* ê */ , (u32)'e' },
|
||||
{ (u32)0xeb /* ë */ , (u32)'e' },
|
||||
{ (u32)0x113 /* ē */ , (u32)'e' },
|
||||
{ (u32)0x115 /* ĕ */ , (u32)'e' },
|
||||
{ (u32)0x117 /* ė */ , (u32)'e' },
|
||||
{ (u32)0x119 /* ę */ , (u32)'e' },
|
||||
{ (u32)0x11b /* ě */ , (u32)'e' },
|
||||
/* g */
|
||||
{ (u32)0x11d /* ĝ */ , (u32)'g' },
|
||||
{ (u32)0x11f /* ğ */ , (u32)'g' },
|
||||
{ (u32)0x121 /* ġ */ , (u32)'g' },
|
||||
{ (u32)0x123 /* ģ */ , (u32)'g' },
|
||||
/* h */
|
||||
{ (u32)0x125 /* ĥ */ , (u32)'h' },
|
||||
{ (u32)0x127 /* ħ */ , (u32)'h' },
|
||||
/* i */
|
||||
{ (u32)0xec /* ì */ , (u32)'i' },
|
||||
{ (u32)0xed /* í */ , (u32)'i' },
|
||||
{ (u32)0xee /* î */ , (u32)'i' },
|
||||
{ (u32)0xef /* ï */ , (u32)'i' },
|
||||
{ (u32)0x129 /* ĩ */ , (u32)'i' },
|
||||
{ (u32)0x12b /* ī */ , (u32)'i' },
|
||||
{ (u32)0x12d /* ĭ */ , (u32)'i' },
|
||||
{ (u32)0x12f /* į */ , (u32)'i' },
|
||||
{ (u32)0x131 /* ı */ , (u32)'i' },
|
||||
/* j */
|
||||
{ (u32)0x135 /* ĵ */ , (u32)'j' },
|
||||
/* k */
|
||||
{ (u32)0x137 /* ķ */ , (u32)'k' },
|
||||
{ (u32)0x138 /* ĸ */ , (u32)'k' },
|
||||
/* l */
|
||||
{ (u32)0x13a /* ĺ */ , (u32)'l' },
|
||||
{ (u32)0x13c /* ļ */ , (u32)'l' },
|
||||
{ (u32)0x13e /* ľ */ , (u32)'l' },
|
||||
{ (u32)0x140 /* ŀ */ , (u32)'l' },
|
||||
{ (u32)0x142 /* ł */ , (u32)'l' },
|
||||
/* n */
|
||||
{ (u32)0xf1 /* ñ */ , (u32)'n' },
|
||||
{ (u32)0x144 /* ń */ , (u32)'n' },
|
||||
{ (u32)0x146 /* ņ */ , (u32)'n' },
|
||||
{ (u32)0x148 /* ň */ , (u32)'n' },
|
||||
{ (u32)0x14a /* Ŋ */ , (u32)'n' },
|
||||
/* o */
|
||||
{ (u32)0xf2 /* ò */ , (u32)'o' },
|
||||
{ (u32)0xf3 /* ó */ , (u32)'o' },
|
||||
{ (u32)0xf4 /* ô */ , (u32)'o' },
|
||||
{ (u32)0xf5 /* õ */ , (u32)'o' },
|
||||
{ (u32)0xf6 /* ö */ , (u32)'o' },
|
||||
{ (u32)0xf9 /* ù */ , (u32)'u' },
|
||||
{ (u32)0xfa /* ú */ , (u32)'u' },
|
||||
{ (u32)0xfb /* û */ , (u32)'u' },
|
||||
{ (u32)0xfc /* ü */ , (u32)'u' },
|
||||
{ (u32)0x14d /* ō */ , (u32)'o' },
|
||||
{ (u32)0x14f /* ŏ */ , (u32)'o' },
|
||||
{ (u32)0x151 /* ő */ , (u32)'o' },
|
||||
/* r */
|
||||
{ (u32)0x155 /* ŕ */ , (u32)'r' },
|
||||
{ (u32)0x157 /* ŗ */ , (u32)'r' },
|
||||
{ (u32)0x159 /* ř */ , (u32)'r' },
|
||||
/* s */
|
||||
{ (u32)0x15b /* ś */ , (u32)'s' },
|
||||
{ (u32)0x15d /* ŝ */ , (u32)'s' },
|
||||
{ (u32)0x15f /* ş */ , (u32)'s' },
|
||||
{ (u32)0x161 /* š */ , (u32)'s' },
|
||||
{ (u32)0x17f /* ſ */ , (u32)'s' },
|
||||
/* t */
|
||||
{ (u32)0x163 /* ţ */ , (u32)'t' },
|
||||
{ (u32)0x165 /* ť */ , (u32)'t' },
|
||||
{ (u32)0x167 /* ŧ */ , (u32)'t' },
|
||||
/* u */
|
||||
{ (u32)0x169 /* ũ */ , (u32)'u' },
|
||||
{ (u32)0x16b /* ū */ , (u32)'u' },
|
||||
{ (u32)0x16d /* ŭ */ , (u32)'u' },
|
||||
{ (u32)0x16f /* ů */ , (u32)'u' },
|
||||
{ (u32)0x171 /* ű */ , (u32)'u' },
|
||||
{ (u32)0x173 /* ų */ , (u32)'u' },
|
||||
/* w */
|
||||
{ (u32)0x175 /* ŵ */ , (u32)'w' },
|
||||
/* y */
|
||||
{ (u32)0xfd /* ý */ , (u32)'y' },
|
||||
{ (u32)0xff /* ÿ */ , (u32)'y' },
|
||||
{ (u32)0x177 /* ŷ */ , (u32)'y' },
|
||||
/* z */
|
||||
{ (u32)0x17a /* ź */ , (u32)'z' },
|
||||
{ (u32)0x17c /* ż */ , (u32)'z' },
|
||||
{ (u32)0x17e /* ž */ , (u32)'z' },
|
||||
};
|
||||
|
||||
/*
|
||||
@ -600,6 +703,7 @@ static int patternCompare(
|
||||
** c or cx.
|
||||
*/
|
||||
if (c <= 0x80) {
|
||||
std::unordered_map<u32, const char*>& charToAccentsMap = charToAccentsInsensitive;
|
||||
char zStop[3];
|
||||
int bMatch;
|
||||
if (noCase) {
|
||||
@ -608,11 +712,23 @@ static int patternCompare(
|
||||
zStop[2] = 0;
|
||||
}
|
||||
else {
|
||||
charToAccentsMap = charToAccentsSensitive;
|
||||
zStop[0] = c;
|
||||
zStop[1] = 0;
|
||||
}
|
||||
while (1) {
|
||||
zString += strcspn((const char*)zString, zStop);
|
||||
/* see if we have a mapping from input character to a list of their
|
||||
respective accented characters; if we do, use that mapping*/
|
||||
auto it = charToAccentsMap.find(c);
|
||||
if (it != charToAccentsMap.end()) {
|
||||
const char* stop = it->second;
|
||||
zString += strcspn((const char*)zString, it->second);
|
||||
}
|
||||
/* otherwise we fall back to the default sqlite implementation that
|
||||
does simple ascii matching */
|
||||
else {
|
||||
zString += strcspn((const char*)zString, zStop);
|
||||
}
|
||||
if (zString[0] == 0) break;
|
||||
zString++;
|
||||
bMatch = patternCompare(zPattern, zString, pInfo, matchOther);
|
||||
|
@ -1078,13 +1078,13 @@ void Indexer::CommitProgress(IIndexerSource* source, unsigned updatedTracks) {
|
||||
}
|
||||
}
|
||||
|
||||
int Indexer::GetLastModifiedTime(IIndexerSource* source, const char* externalId) {
|
||||
int64_t Indexer::GetLastModifiedTime(IIndexerSource* source, const char* externalId) {
|
||||
if (source && externalId && strlen(externalId)) {
|
||||
db::Statement stmt("SELECT filetime FROM tracks t where source_id=? AND external_id=?", dbConnection);
|
||||
stmt.BindInt32(0, source->SourceId());
|
||||
stmt.BindText(1, externalId);
|
||||
if (stmt.Step() == db::Row) {
|
||||
return stmt.ColumnInt32(0);
|
||||
return stmt.ColumnInt64(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ namespace musik { namespace core {
|
||||
bool RemoveByExternalId(musik::core::sdk::IIndexerSource* source, const char* id) override;
|
||||
int RemoveAll(musik::core::sdk::IIndexerSource* source) override;
|
||||
void CommitProgress(musik::core::sdk::IIndexerSource* source, unsigned updatedTracks) override;
|
||||
int GetLastModifiedTime(musik::core::sdk::IIndexerSource* source, const char* id) override;
|
||||
int64_t GetLastModifiedTime(musik::core::sdk::IIndexerSource* source, const char* id) override;
|
||||
|
||||
bool Save(
|
||||
musik::core::sdk::IIndexerSource* source,
|
||||
|
@ -271,7 +271,7 @@ bool IndexerTrack::NeedsToBeIndexed(
|
||||
}
|
||||
|
||||
const size_t fileSize = (size_t) std::filesystem::file_size(file);
|
||||
const size_t fileTime = (size_t)duration_cast<milliseconds>(
|
||||
const int64_t fileTime = (int64_t) duration_cast<milliseconds>(
|
||||
std::filesystem::last_write_time(file).time_since_epoch()).count();
|
||||
|
||||
this->SetValue("filesize", std::to_string(fileSize).c_str());
|
||||
@ -289,7 +289,7 @@ bool IndexerTrack::NeedsToBeIndexed(
|
||||
if (stmt.Step() == db::Row) {
|
||||
this->trackId = stmt.ColumnInt64(0);
|
||||
const int dbFileSize = stmt.ColumnInt32(2);
|
||||
const int dbFileTime = stmt.ColumnInt32(3);
|
||||
const int64_t dbFileTime = stmt.ColumnInt64(3);
|
||||
|
||||
if (fileSize == dbFileSize && fileTime == dbFileTime) {
|
||||
return false;
|
||||
@ -304,11 +304,13 @@ bool IndexerTrack::NeedsToBeIndexed(
|
||||
|
||||
static int stringToInt(const std::string& str, const int defaultValue) {
|
||||
try {
|
||||
return std::stoi(str, 0, 10);
|
||||
if (str.size()) {
|
||||
return std::stoi(str, 0, 10);
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
return defaultValue;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static int64_t writeToTracksTable(
|
||||
@ -357,6 +359,8 @@ static int64_t writeToTracksTable(
|
||||
|
||||
db::Statement stmt(query.c_str(), dbConnection);
|
||||
|
||||
auto time = track.GetInt64("filetime");
|
||||
|
||||
stmt.BindInt32(0, stringToInt(track.GetString("track"), 1));
|
||||
stmt.BindInt32(1, stringToInt(track.GetString("disc"), 1));
|
||||
stmt.BindText(2, track.GetString("bpm"));
|
||||
@ -364,7 +368,7 @@ static int64_t writeToTracksTable(
|
||||
stmt.BindInt32(4, track.GetInt32("filesize"));
|
||||
stmt.BindText(5, track.GetString("title"));
|
||||
stmt.BindText(6, track.GetString("filename"));
|
||||
stmt.BindInt32(7, track.GetInt32("filetime"));
|
||||
stmt.BindInt64(7, track.GetInt64("filetime"));
|
||||
stmt.BindInt64(8, track.GetInt64("path_id"));
|
||||
stmt.BindText(9, track.GetString("external_id"));
|
||||
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <functional>
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
#include "String.h"
|
||||
|
||||
#ifdef WIN32
|
||||
@ -69,21 +71,9 @@ namespace musik { namespace core { namespace sdk { namespace fs {
|
||||
}
|
||||
|
||||
template <typename String=std::string>
|
||||
static int getLastModifiedTime(const String& fn) {
|
||||
#ifdef WIN32
|
||||
/* todo */
|
||||
struct _stat result = { 0 };
|
||||
std::wstring fn16 = musik::core::sdk::str::u8to16(fn.c_str());
|
||||
if (_wstat(fn16.c_str(), &result) == 0) {
|
||||
return (int)result.st_mtime;
|
||||
}
|
||||
#else
|
||||
struct stat result = { 0 };
|
||||
if (stat(fn.c_str(), &result) == 0) {
|
||||
return result.st_mtime;
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
static int64_t getLastModifiedTime(const String& fn) {
|
||||
return (int64_t) std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::filesystem::last_write_time(std::filesystem::u8path(fn)).time_since_epoch()).count();
|
||||
}
|
||||
|
||||
template <typename String=std::string>
|
||||
|
@ -48,7 +48,7 @@ namespace musik { namespace core { namespace sdk {
|
||||
virtual bool RemoveByUri(IIndexerSource* source, const char* uri) = 0;
|
||||
virtual bool RemoveByExternalId(IIndexerSource* source, const char* id) = 0;
|
||||
virtual int RemoveAll(IIndexerSource* source) = 0;
|
||||
virtual int GetLastModifiedTime(IIndexerSource* source, const char* externalId) = 0;
|
||||
virtual int64_t GetLastModifiedTime(IIndexerSource* source, const char* externalId) = 0;
|
||||
};
|
||||
|
||||
} } }
|
||||
|
@ -39,7 +39,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 99
|
||||
#define VERSION_PATCH 1
|
||||
#define VERSION_COMMIT_HASH "#517b9fdf"
|
||||
#define VERSION_COMMIT_HASH "#54952980"
|
||||
#define VERSION "0.99.1"
|
||||
|
||||
namespace musik {
|
||||
|
@ -153,7 +153,7 @@ int64_t CategoryListView::GetSelectedId() {
|
||||
if (index != NO_SELECTION && this->metadata && index < this->metadata->Count()) {
|
||||
return this->metadata->At(index)->GetId();
|
||||
}
|
||||
return this->selectAfterQuery == -1LL ? -1LL : this->selectAfterQuery;
|
||||
return this->selectAfterQuery == -1LL || this->metadata->Count() == 0 ? -1LL : this->selectAfterQuery;
|
||||
}
|
||||
|
||||
std::string CategoryListView::GetSelectedValue() {
|
||||
|
@ -150,9 +150,9 @@ void GmeIndexerSource::UpdateMetadata(
|
||||
{
|
||||
/* only need to do this check once, and it's relatively expensive because
|
||||
it requires a db read. cache we've already done it. */
|
||||
int modifiedTime = fs::getLastModifiedTime(fn);
|
||||
int64_t modifiedTime = fs::getLastModifiedTime(fn);
|
||||
const std::string firstExternalId = indexer::createExternalId(EXTERNAL_ID_PREFIX, fn, 0);
|
||||
int modifiedDbTime = indexer->GetLastModifiedTime(this, firstExternalId.c_str());
|
||||
int64_t modifiedDbTime = indexer->GetLastModifiedTime(this, firstExternalId.c_str());
|
||||
if (modifiedDbTime < 0 || modifiedTime != modifiedDbTime) {
|
||||
fn = fs::canonicalizePath(fn);
|
||||
|
||||
|
@ -171,9 +171,9 @@ void OpenMptIndexerSource::UpdateMetadata(
|
||||
{
|
||||
/* only need to do this check once, and it's relatively expensive because
|
||||
it requires a db read. cache we've already done it. */
|
||||
int modifiedTime = fs::getLastModifiedTime(fn);
|
||||
int64_t modifiedTime = fs::getLastModifiedTime(fn);
|
||||
const std::string firstExternalId = indexer::createExternalId(PLUGIN_NAME, fn, 0);
|
||||
int modifiedDbTime = indexer->GetLastModifiedTime(this, firstExternalId.c_str());
|
||||
int64_t modifiedDbTime = indexer->GetLastModifiedTime(this, firstExternalId.c_str());
|
||||
if (modifiedDbTime < 0 || modifiedTime != modifiedDbTime) {
|
||||
fn = fs::canonicalizePath(fn);
|
||||
char* fileBytes = nullptr;
|
||||
|
@ -146,7 +146,12 @@ static TagLib::FileRef resolveOggType(const char* uri) {
|
||||
}
|
||||
|
||||
static bool isValidYear(const std::string& year) {
|
||||
return std::stoi(year) > 0;
|
||||
try {
|
||||
return year.size() && std::stoi(year) > 0;
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static float toReplayGainFloat(const std::string& input) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user