wxWidgets wxMemoryFS bug with filenames

This one drove me crazy this afternoon, using wxWidgets 2.8.8. Not the most recent, but I haven't found any notes that says it's been fixed.
I added a file to a MemoryFS
wxString name = "C:\data\my_file.txt";
wxMemoryFSHandler::AddFile(name, out_s.GetString());
//(where second arg is the file contents as a string)

but then I couldn't retrieve it:
wxFileSystem fs;
wxFSFile *fs_file = fs.OpenFile("memory:"+name);
if (!fs_file) return; // fs_file always NULL, so I'd get an early return

Turns out, when trying to look up the file, filesys.cpp:: MakeCorrectPath is called on the string that's passed in, so it converted back-slashes to forward-slashes, and the names weren't equivalent. I did this:
wxString name = "C:\data\my_file.txt";
name.Replace("\\", "/");
wxMemoryFSHandler::AddFile(name, out_s.GetString());

and now I'm able to retrieve it.
8Oct 10 Update: I submitted a defect.
Post a Comment

Popular posts from this blog

Inno Setup custom data directory location

Inno Setup MSVC vcredist without bothering your users

Followup: Ubuntu persistent USB console boot, or why won't my car read this USB stick?