OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [os/] [stat_solaris.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2011 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package os
6
 
7
import (
8
        "syscall"
9
        "time"
10
)
11
 
12
func sameFile(sys1, sys2 interface{}) bool {
13
        stat1 := sys1.(*syscall.Stat_t)
14
        stat2 := sys2.(*syscall.Stat_t)
15
        return stat1.Dev == stat2.Dev && stat1.Ino == stat2.Ino
16
}
17
 
18
func fileInfoFromStat(st *syscall.Stat_t, name string) FileInfo {
19
        fs := &fileStat{
20
                name:    basename(name),
21
                size:    int64(st.Size),
22
                modTime: timestrucToTime(st.Mtime),
23
                sys:     st,
24
        }
25
        fs.mode = FileMode(st.Mode & 0777)
26
        switch st.Mode & syscall.S_IFMT {
27
        case syscall.S_IFBLK, syscall.S_IFCHR:
28
                fs.mode |= ModeDevice
29
        case syscall.S_IFDIR:
30
                fs.mode |= ModeDir
31
        case syscall.S_IFIFO:
32
                fs.mode |= ModeNamedPipe
33
        case syscall.S_IFLNK:
34
                fs.mode |= ModeSymlink
35
        case syscall.S_IFREG:
36
                // nothing to do
37
        case syscall.S_IFSOCK:
38
                fs.mode |= ModeSocket
39
        }
40
        if st.Mode&syscall.S_ISGID != 0 {
41
                fs.mode |= ModeSetgid
42
        }
43
        if st.Mode&syscall.S_ISUID != 0 {
44
                fs.mode |= ModeSetuid
45
        }
46
        return fs
47
}
48
 
49
func timestrucToTime(ts syscall.Timestruc) time.Time {
50
        return time.Unix(int64(ts.Sec), int64(ts.Nsec))
51
}
52
 
53
// For testing.
54
func atime(fi FileInfo) time.Time {
55
        return timestrucToTime(fi.(*fileStat).Sys().(*syscall.Stat_t).Atime)
56
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.