8000 Merge pull request #329 from pkg/issue-291-ifmt-platform-fix · etherscan-io/sftp@e6f3825 · GitHub
[go: up one dir, main page]

Skip to content

Commit e6f3825

Browse files
authored
Merge pull request pkg#329 from pkg/issue-291-ifmt-platform-fix
fix S_IFMT value on windows, plan9 and js/wasm
2 parents f3d1308 + 0277caa commit e6f3825

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

attrs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ const (
1616
sshFileXferAttrACmodTime = 0x00000008
1717
sshFileXferAttrExtented = 0x80000000
1818

19-
sshFileXferAttrAll = sshFileXferAttrSize|sshFileXferAttrUIDGID|sshFileXferAttrPermissions|
20-
sshFileXferAttrACmodTime|sshFileXferAttrExtented
19+
sshFileXferAttrAll = sshFileXferAttrSize | sshFileXferAttrUIDGID | sshFileXferAttrPermissions |
20+
sshFileXferAttrACmodTime | sshFileXferAttrExtented
2121
)
2222

2323
// fileInfo is an artificial type designed to satisfy os.FileInfo.
@@ -176,7 +176,7 @@ func marshalFileInfo(b []byte, fi os.FileInfo) []byte {
176176
// toFileMode converts sftp filemode bits to the os.FileMode specification
177177
func toFileMode(mode uint32) os.FileMode {
178178
var fm = os.FileMode(mode & 0777)
179-
switch mode & syscall.S_IFMT {
179+
switch mode & S_IFMT {
180180
case syscall.S_IFBLK:
181181
fm |= os.ModeDevice
182182
case syscall.S_IFCHR:

syscall_fixed.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// +build plan9 windows js,wasm
2+
3+
// Go defines S_IFMT on windows, plan9 and js/wasm as 0x1f000 instead of
4+
// 0xf000. None of the the other S_IFxyz values include the "1" (in 0x1f000)
5+
// which prevents them from matching the bitmask.
6+
7+
package sftp
8+
9+
const S_IFMT = 0xf000

syscall_good.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// +build !plan9,!windows
2+
// +build !js !wasm
3+
4+
package sftp
5+
6+
import "syscall"
7+
8+
const S_IFMT = syscall.S_IFMT

0 commit comments

Comments
 (0)
0