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 ( | 7 import ( |
8 "syscall" | 8 "syscall" |
9 "time" | 9 "time" |
10 ) | 10 ) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 ModeSticky // t: sticky | 51 ModeSticky // t: sticky |
52 | 52 |
53 // Mask for the type bits. For regular files, none will be set. | 53 // Mask for the type bits. For regular files, none will be set. |
54 ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevi
ce | 54 ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevi
ce |
55 | 55 |
56 ModePerm FileMode = 0777 // permission bits | 56 ModePerm FileMode = 0777 // permission bits |
57 ) | 57 ) |
58 | 58 |
59 func (m FileMode) String() string { | 59 func (m FileMode) String() string { |
60 const str = "dalTLDpSugct" | 60 const str = "dalTLDpSugct" |
61 » const rwx = "rwxrwxrwx" | 61 » var buf [32]byte // Mode is uint32. |
62 » var buf [len(str) + len(rwx)]byte | |
63 w := 0 | 62 w := 0 |
64 for i, c := range str { | 63 for i, c := range str { |
65 if m&(1<<uint(32-1-i)) != 0 { | 64 if m&(1<<uint(32-1-i)) != 0 { |
66 buf[w] = byte(c) | 65 buf[w] = byte(c) |
67 w++ | 66 w++ |
68 } | 67 } |
69 } | 68 } |
70 if w == 0 { | 69 if w == 0 { |
71 buf[w] = '-' | 70 buf[w] = '-' |
72 w++ | 71 w++ |
73 } | 72 } |
| 73 const rwx = "rwxrwxrwx" |
74 for i, c := range rwx { | 74 for i, c := range rwx { |
75 if m&(1<<uint(9-1-i)) != 0 { | 75 if m&(1<<uint(9-1-i)) != 0 { |
76 buf[w] = byte(c) | 76 buf[w] = byte(c) |
77 } else { | 77 } else { |
78 buf[w] = '-' | 78 buf[w] = '-' |
79 } | 79 } |
80 w++ | 80 w++ |
81 } | 81 } |
82 return string(buf[:w]) | 82 return string(buf[:w]) |
83 } | 83 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // SameFile only applies to results returned by this package's Stat. | 116 // SameFile only applies to results returned by this package's Stat. |
117 // It returns false in other cases. | 117 // It returns false in other cases. |
118 func SameFile(fi1, fi2 FileInfo) bool { | 118 func SameFile(fi1, fi2 FileInfo) bool { |
119 fs1, ok1 := fi1.(*fileStat) | 119 fs1, ok1 := fi1.(*fileStat) |
120 fs2, ok2 := fi2.(*fileStat) | 120 fs2, ok2 := fi2.(*fileStat) |
121 if !ok1 || !ok2 { | 121 if !ok1 || !ok2 { |
122 return false | 122 return false |
123 } | 123 } |
124 return sameFile(fs1.sys, fs2.sys) | 124 return sameFile(fs1.sys, fs2.sys) |
125 } | 125 } |
LEFT | RIGHT |