I'm going to replace remaing GLib path management functions. However I have some thoughts at first:
I think PathTraits type could be split into two types. One for native paths and one for UTF-8 paths. They could have similar symbol names (e.g. Build, IsAbsolute). This would allow writing more general path management algorithms using templates with specific traits template parameter. On contrary there would be only few functions so copy-and-paste solution might no so bad (easier to read, faster compile, etc). This function looks suspicious for me: std::string PathTraits::GetParentUTF8(const char *p) { assert(p != nullptr); const char *slash = strrchr(p, SEPARATOR_UTF8); return slash != nullptr ? std::string(p, slash) : std::string("."); } If given rooted path (for example '/foo') it would return empty string which is not valid path. This might be OK for MPD virtual UTF-8 paths, however it's definitely not OK for real paths because empty string is never a valid directory. This leaves me in twofold situation. If I implement GetParentFS() to return '/' if given rooted path it would be inconsistent with GetParentUTF8(). If I change GetParentUTF8() to return '/' if given rooted path I'm not sure if this won't break anything in database operation and other places. One more suspicious thing is PathToUTF8() function: On Windows we accept both '/' and '\' as path separators. However UTF-8 paths always use '/'. This means if path that contains backslashes is converted to UTF-8 it can not be safely returned to client because it would treated incorrectly (I assume MPD protocol does not have special meaning of backslash). From what I saw in the code this functions is mostly used in logging, which is safe. But I'm not sure if there are no hidden bugs in this logic. -- Denis ------------------------------------------------------------------------------ Sponsored by Intel(R) XDK Develop, test and display web and hybrid apps with a single code base. Download it for free now! http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk _______________________________________________ Musicpd-dev-team mailing list Musicpd-dev-team@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team