diff options
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs index 0f8f88efd2..f5a55cf727 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/FilePath.cs @@ -172,11 +172,15 @@ namespace MonoDevelop.Core }
public bool IsChildPathOf (FilePath basePath)
- {
- if (basePath.fileName [basePath.fileName.Length - 1] != Path.DirectorySeparatorChar)
- return fileName.StartsWith (basePath.fileName + Path.DirectorySeparatorChar, PathComparison); - else
- return fileName.StartsWith (basePath.fileName, PathComparison); + { + bool startsWith = fileName.StartsWith (basePath.fileName, PathComparison); + if (startsWith && basePath.fileName [basePath.fileName.Length - 1] != Path.DirectorySeparatorChar) {
+ // If the last character isn't a path separator character, check whether the string we're searching in
+ // has more characters than the string we're looking for then check the character. + if (fileName.Length > basePath.fileName.Length) + startsWith &= fileName [basePath.fileName.Length] == Path.DirectorySeparatorChar; + } + return startsWith;
}
public FilePath ChangeExtension (string ext)
|