"time"
)
-const _BIT16SZ = 2
+const bitSize16 = 2
func fileInfoFromStat(d *syscall.Dir) FileInfo {
fs := &fileStat{
size := syscall.STATFIXLEN + 16*4
for i := 0; i < 2; i++ {
- buf := make([]byte, _BIT16SZ+size)
+ buf := make([]byte, bitSize16+size)
var n int
switch a := arg.(type) {
panic("phase error in dirstat")
}
- if n < _BIT16SZ {
+ if n < bitSize16 {
return nil, &PathError{"stat", name, err}
}
import "unsafe"
const ImplementsGetwd = true
+const bitSize16 = 2
// ErrorString implements Error's String method by returning itself.
type ErrorString string
}
func Mkdir(path string, mode uint32) (err error) {
+ // If path exists and is not a directory, Create will fail silently.
+ // Work around this by rejecting Mkdir if path exists.
+ statbuf := make([]byte, bitSize16)
+ // Remove any trailing slashes from path, otherwise the Stat will
+ // fail with ENOTDIR.
+ n := len(path)
+ for n > 1 && path[n-1] == '/' {
+ n--
+ }
+ _, err = Stat(path[0:n], statbuf)
+ if err == nil {
+ return EEXIST
+ }
+
fd, err := Create(path, O_RDONLY, DMDIR|mode)
if fd != -1 {