summaryrefslogtreecommitdiffstats
path: root/tools/gn/filesystem_utils.h
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 23:26:40 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-27 23:26:40 +0000
commit858ceda682777affb22d41ee99adedeac946431b (patch)
tree50fb1d7d1f9a2661c3382a4d5f9a977f9240f62c /tools/gn/filesystem_utils.h
parent0329bef28e5938a0fc6a1953c313aac3f205f4eb (diff)
downloadchromium_src-858ceda682777affb22d41ee99adedeac946431b.zip
chromium_src-858ceda682777affb22d41ee99adedeac946431b.tar.gz
chromium_src-858ceda682777affb22d41ee99adedeac946431b.tar.bz2
Do more slash normalization in GN.
This makes GN more aggressive about converting backslashes into forward-slashes, and makes the path handling functions mostly indifferent with regard to the two types of slashes. The previous behavior was a bit confusing in that you would end up with strings like "//out\Debug/" on Windows, and certain operations on this would fail. With this change, the backslash will be more aggressively converted. The downside is that Posix filenames with literal backslashes in them are now unrepresentable in GN. But I think for a cross-platform system on constrained input (build files) this is a reasonable tradeoff for more consistent path handling. R=scottmg@chromium.org Review URL: https://codereview.chromium.org/177003008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253969 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/gn/filesystem_utils.h')
-rw-r--r--tools/gn/filesystem_utils.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/gn/filesystem_utils.h b/tools/gn/filesystem_utils.h
index ba08635..f720987 100644
--- a/tools/gn/filesystem_utils.h
+++ b/tools/gn/filesystem_utils.h
@@ -76,6 +76,13 @@ base::StringPiece FindFilenameNoExtension(const std::string* path);
// preserved.
void RemoveFilename(std::string* path);
+// Returns if the given character is a slash. This allows both slashes and
+// backslashes for consistency between Posix and Windows (as opposed to
+// FilePath::IsSeparator which is based on the current platform).
+inline bool IsSlash(const char ch) {
+ return ch == '/' || ch == '\\';
+}
+
// Returns true if the given path ends with a slash.
bool EndsWithSlash(const std::string& s);