Skip to content

Commit

Permalink
Implement FilePath.Equals() and GetHashCode()
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk authored and nulltoken committed Jun 14, 2012
1 parent 1f12511 commit e075315
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions LibGit2Sharp/Core/FilePath.cs
@@ -1,8 +1,9 @@
using System.IO;
using System;
using System.IO;

namespace LibGit2Sharp.Core
{
internal class FilePath
internal class FilePath : IEquatable<FilePath>
{
internal static FilePath Empty = new FilePath(string.Empty);

Expand Down Expand Up @@ -56,5 +57,20 @@ private static string Replace(string path, char oldChar, char newChar)

return path == null ? null : path.Replace(oldChar, newChar);
}

public bool Equals(FilePath other)
{
return other == null ? posix == null : string.Equals(posix, other.posix, StringComparison.Ordinal);
}

public override bool Equals(object obj)
{
return Equals(obj as FilePath);
}

public override int GetHashCode()
{
return posix == null ? 0 : posix.GetHashCode();
}
}
}

0 comments on commit e075315

Please sign in to comment.