| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 String DOMFilePath::GetDirectory(const String& path) { | 59 String DOMFilePath::GetDirectory(const String& path) { |
| 60 int index = path.ReverseFind(DOMFilePath::kSeparator); | 60 int index = path.ReverseFind(DOMFilePath::kSeparator); |
| 61 if (!index) | 61 if (!index) |
| 62 return DOMFilePath::kRoot; | 62 return DOMFilePath::kRoot; |
| 63 if (index != -1) | 63 if (index != -1) |
| 64 return path.Substring(0, index); | 64 return path.Substring(0, index); |
| 65 return "."; | 65 return "."; |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool DOMFilePath::IsParentOf(const String& parent, const String& may_be_child) { | 68 bool DOMFilePath::IsParentOf(const String& parent, const String& may_be_child) { |
| 69 ASSERT(DOMFilePath::IsAbsolute(parent)); | 69 DCHECK(DOMFilePath::IsAbsolute(parent)); |
| 70 ASSERT(DOMFilePath::IsAbsolute(may_be_child)); | 70 DCHECK(DOMFilePath::IsAbsolute(may_be_child)); |
| 71 if (parent == DOMFilePath::kRoot && may_be_child != DOMFilePath::kRoot) | 71 if (parent == DOMFilePath::kRoot && may_be_child != DOMFilePath::kRoot) |
| 72 return true; | 72 return true; |
| 73 if (parent.length() >= may_be_child.length() || | 73 if (parent.length() >= may_be_child.length() || |
| 74 !may_be_child.StartsWith(parent, kTextCaseUnicodeInsensitive)) | 74 !may_be_child.StartsWith(parent, kTextCaseUnicodeInsensitive)) |
| 75 return false; | 75 return false; |
| 76 if (may_be_child[parent.length()] != DOMFilePath::kSeparator) | 76 if (may_be_child[parent.length()] != DOMFilePath::kSeparator) |
| 77 return false; | 77 return false; |
| 78 return true; | 78 return true; |
| 79 } | 79 } |
| 80 | 80 |
| 81 String DOMFilePath::RemoveExtraParentReferences(const String& path) { | 81 String DOMFilePath::RemoveExtraParentReferences(const String& path) { |
| 82 ASSERT(DOMFilePath::IsAbsolute(path)); | 82 DCHECK(DOMFilePath::IsAbsolute(path)); |
| 83 Vector<String> components; | 83 Vector<String> components; |
| 84 Vector<String> canonicalized; | 84 Vector<String> canonicalized; |
| 85 path.Split(DOMFilePath::kSeparator, components); | 85 path.Split(DOMFilePath::kSeparator, components); |
| 86 for (size_t i = 0; i < components.size(); ++i) { | 86 for (size_t i = 0; i < components.size(); ++i) { |
| 87 if (components[i] == ".") | 87 if (components[i] == ".") |
| 88 continue; | 88 continue; |
| 89 if (components[i] == "..") { | 89 if (components[i] == "..") { |
| 90 if (canonicalized.size() > 0) | 90 if (canonicalized.size() > 0) |
| 91 canonicalized.pop_back(); | 91 canonicalized.pop_back(); |
| 92 continue; | 92 continue; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 bool DOMFilePath::IsValidName(const String& name) { | 132 bool DOMFilePath::IsValidName(const String& name) { |
| 133 if (name.IsEmpty()) | 133 if (name.IsEmpty()) |
| 134 return true; | 134 return true; |
| 135 // '/' is not allowed in name. | 135 // '/' is not allowed in name. |
| 136 if (name.Contains('/')) | 136 if (name.Contains('/')) |
| 137 return false; | 137 return false; |
| 138 return IsValidPath(name); | 138 return IsValidPath(name); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace blink | 141 } // namespace blink |
| OLD | NEW |