win: asar: Support "\" as path separator

This commit is contained in:
Cheng Zhao 2014-09-30 20:12:18 +08:00
parent 927ec6ab7a
commit 301014e4a6

View file

@ -18,6 +18,12 @@ namespace asar {
namespace { namespace {
#if defined(OS_WIN)
const char kSeparators[] = "\\/";
#else
const char kSeparators[] = "/";
#endif
bool GetNodeFromPath(std::string path, bool GetNodeFromPath(std::string path,
const base::DictionaryValue* root, const base::DictionaryValue* root,
const base::DictionaryValue** out); const base::DictionaryValue** out);
@ -58,9 +64,9 @@ bool GetNodeFromPath(std::string path,
} }
const base::DictionaryValue* dir = root; const base::DictionaryValue* dir = root;
for (size_t delimiter_position = path.find('/'); for (size_t delimiter_position = path.find_first_of(kSeparators);
delimiter_position != std::string::npos; delimiter_position != std::string::npos;
delimiter_position = path.find('/')) { delimiter_position = path.find_first_of(kSeparators)) {
const base::DictionaryValue* child = NULL; const base::DictionaryValue* child = NULL;
if (!GetChildNode(root, path.substr(0, delimiter_position), dir, &child)) if (!GetChildNode(root, path.substr(0, delimiter_position), dir, &child))
return false; return false;