Skip to content

Commit 666d946

Browse files
committed
Implement diff.compareSysStat on windows
and update diff tests to work with slash paths on windows Signed-off-by: Daniel Nephin <dnephin@gmail.com>
1 parent 5025b53 commit 666d946

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

fs/diff_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,20 +322,20 @@ func changesString(c []TestChange) string {
322322
func Add(p string) TestChange {
323323
return TestChange{
324324
Kind: ChangeKindAdd,
325-
Path: p,
325+
Path: filepath.FromSlash(p),
326326
}
327327
}
328328

329329
func Delete(p string) TestChange {
330330
return TestChange{
331331
Kind: ChangeKindDelete,
332-
Path: p,
332+
Path: filepath.FromSlash(p),
333333
}
334334
}
335335

336336
func Modify(p string) TestChange {
337337
return TestChange{
338338
Kind: ChangeKindModify,
339-
Path: p,
339+
Path: filepath.FromSlash(p),
340340
}
341341
}

fs/diff_windows.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
package fs
22

3-
import "os"
3+
import (
4+
"os"
5+
6+
"golang.org/x/sys/windows"
7+
)
48

59
func detectDirDiff(upper, lower string) *diffDirOptions {
610
return nil
711
}
812

913
func compareSysStat(s1, s2 interface{}) (bool, error) {
10-
// TODO: Use windows specific sys type
11-
return false, nil
14+
f1, ok := s1.(windows.Win32FileAttributeData)
15+
if !ok {
16+
return false, nil
17+
}
18+
f2, ok := s2.(windows.Win32FileAttributeData)
19+
if !ok {
20+
return false, nil
21+
}
22+
return f1.FileAttributes == f2.FileAttributes, nil
1223
}
1324

1425
func compareCapabilities(p1, p2 string) (bool, error) {

0 commit comments

Comments
 (0)