|
|
@ -121,17 +121,16 @@ func readDirN(dirPath string, count int) (entries []string, err error) { |
|
|
|
data := &syscall.Win32finddata{} |
|
|
|
data := &syscall.Win32finddata{} |
|
|
|
|
|
|
|
|
|
|
|
for count != 0 { |
|
|
|
for count != 0 { |
|
|
|
e := syscall.FindNextFile(syscall.Handle(d.Fd()), data) |
|
|
|
err = syscall.FindNextFile(syscall.Handle(d.Fd()), data) |
|
|
|
if e != nil { |
|
|
|
if err != nil { |
|
|
|
if e == syscall.ERROR_NO_MORE_FILES { |
|
|
|
if err == syscall.ERROR_NO_MORE_FILES { |
|
|
|
break |
|
|
|
break |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
err = &os.PathError{ |
|
|
|
return nil, &os.PathError{ |
|
|
|
Op: "FindNextFile", |
|
|
|
Op: "FindNextFile", |
|
|
|
Path: dirPath, |
|
|
|
Path: dirPath, |
|
|
|
Err: e, |
|
|
|
Err: err, |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
name := syscall.UTF16ToString(data.FileName[0:]) |
|
|
|
name := syscall.UTF16ToString(data.FileName[0:]) |
|
|
@ -140,23 +139,7 @@ func readDirN(dirPath string, count int) (entries []string, err error) { |
|
|
|
} |
|
|
|
} |
|
|
|
switch { |
|
|
|
switch { |
|
|
|
case data.FileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT != 0: |
|
|
|
case data.FileAttributes&syscall.FILE_ATTRIBUTE_REPARSE_POINT != 0: |
|
|
|
// If its symbolic link, follow the link using os.Stat()
|
|
|
|
|
|
|
|
var fi os.FileInfo |
|
|
|
|
|
|
|
fi, err = os.Stat(pathJoin(dirPath, name)) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
// If file does not exist, we continue and skip it.
|
|
|
|
|
|
|
|
// Could happen if it was deleted in the middle while
|
|
|
|
|
|
|
|
// this list was being performed.
|
|
|
|
|
|
|
|
if os.IsNotExist(err) { |
|
|
|
|
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if fi.IsDir() { |
|
|
|
|
|
|
|
entries = append(entries, name+SlashSeparator) |
|
|
|
|
|
|
|
} else if fi.Mode().IsRegular() { |
|
|
|
|
|
|
|
entries = append(entries, name) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case data.FileAttributes&syscall.FILE_ATTRIBUTE_DIRECTORY != 0: |
|
|
|
case data.FileAttributes&syscall.FILE_ATTRIBUTE_DIRECTORY != 0: |
|
|
|
entries = append(entries, name+SlashSeparator) |
|
|
|
entries = append(entries, name+SlashSeparator) |
|
|
|
default: |
|
|
|
default: |
|
|
|