LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package os | 5 package os |
6 | 6 |
7 import "syscall" | 7 import "syscall" |
8 | 8 |
9 func isSymlink(stat *syscall.Stat_t) bool { | 9 func isSymlink(stat *syscall.Stat_t) bool { |
10 » return stat.Mode&syscall.S_IFMT == syscall.S_IFLNK | 10 » panic("windows isSymlink not implemented") |
11 } | 11 } |
12 | 12 |
13 func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir { | 13 func dirFromStat(name string, dir *Dir, lstat, stat *syscall.Stat_t) *Dir { |
14 » dir.Dev = uint64(stat.Dev) | 14 » panic("windows dirFromStat not implemented") |
15 » dir.Ino = uint64(stat.Ino) | |
16 » dir.Nlink = uint64(stat.Nlink) | |
17 » dir.Mode = stat.Mode | |
18 » dir.Uid = stat.Uid | |
19 » dir.Gid = stat.Gid | |
20 » dir.Rdev = uint64(stat.Rdev) | |
21 » dir.Size = uint64(stat.Size) | |
22 » dir.Blksize = uint64(stat.Blksize) | |
23 » dir.Blocks = uint64(stat.Blocks) | |
24 » dir.Atime_ns = uint64(stat.Atime) * 1e9 | |
25 » dir.Mtime_ns = uint64(stat.Mtime) * 1e9 | |
26 » dir.Ctime_ns = uint64(stat.Ctime) * 1e9 | |
27 » for i := len(name) - 1; i >= 0; i-- { | |
28 » » if name[i] == '/' { | |
29 » » » name = name[i+1:] | |
30 » » » break | |
31 » » } | |
32 » } | |
33 » dir.Name = name | |
34 » if isSymlink(lstat) && !isSymlink(stat) { | |
35 » » dir.FollowedSymlink = true | |
36 » } | |
37 » return dir | |
38 } | 15 } |
LEFT | RIGHT |