We need FileSpec::Dump() to format the result according to the paths' internal path syntax. So this means backslashes on windows, for example. GetPath already has the ability to do this, but GetPath was calling Dump and then adding the denormalization logic on top of that. So the change here is to make it work the other way around. Have GetPath call dump instead, and then just append the trailing slash if necessary. This way Dump can just call GetPath(true).
Details
- Reviewers
- None
Diff Detail
Event Timeline
source/Host/common/FileSpec.cpp | ||
---|---|---|
845 | Ignore this line, I had it in for debugging purposes. Forgot to remove it before uploading. |
source/Host/common/FileSpec.cpp | ||
---|---|---|
629 | Ahh, I think I need to fix the endswith() check in GetPath instead. Previously GetPath() was calling Dump with trailing_slash=false, so that means anyone calling GetPath() directly was getting back something that never had a trailing slash. But with this change, it's possible for a direct call to GetPath() to include a trailing slash. So if I fix it there, I can just remove this whole branch and the entire function is just if (s) s->PutCString(GetPath().c_str()); |
Let's see if this is better. GetPath() should now NEVER append a trailing slash, and Dump() should now ALWAYS append a trailing slash. there were no users of Dump() passing false, so I assume the ability to choose wasn't needed, which is why I removed the argument.
source/Host/common/FileSpec.cpp | ||
---|---|---|
844 | Nevermind, you trimmed away the single '/'. But there's another problem if m_directory == '/' and m_filename is empty, you return an empty string. |
GetPath() is supposed to have not put a trailing slash in that case. See
the call to rtrim() in GetPath()
How about just s->PutCString(GetPath().c_str())?