Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
cad7a3ae
Commit
cad7a3ae
authored
Feb 09, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simple accessors for Dir mode bits
R=rsc DELTA=71 (71 added, 0 deleted, 0 changed) OCL=24687 CL=24694
parent
a948fdd6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
0 deletions
+71
-0
os_types.go
src/lib/os/os_types.go
+34
-0
types_amd64_darwin.go
src/lib/syscall/types_amd64_darwin.go
+19
-0
types_amd64_linux.go
src/lib/syscall/types_amd64_linux.go
+18
-0
No files found.
src/lib/os/os_types.go
View file @
cad7a3ae
...
...
@@ -4,6 +4,8 @@
package
os
import
"syscall"
// An operating-system independent representation of Unix data structures.
// OS-specific routines in this directory convert the OS-local versions to these.
...
...
@@ -24,3 +26,35 @@ type Dir struct {
Ctime_ns
uint64
;
// nanoseconds since 1970
Name
string
;
}
func
(
dir
*
Dir
)
IsFifo
()
bool
{
return
(
dir
.
Mode
&
syscall
.
S_IFMT
)
==
syscall
.
S_IFIFO
}
func
(
dir
*
Dir
)
IsChar
()
bool
{
return
(
dir
.
Mode
&
syscall
.
S_IFMT
)
==
syscall
.
S_IFCHR
}
func
(
dir
*
Dir
)
IsDirectory
()
bool
{
return
(
dir
.
Mode
&
syscall
.
S_IFMT
)
==
syscall
.
S_IFDIR
}
func
(
dir
*
Dir
)
IsBlock
()
bool
{
return
(
dir
.
Mode
&
syscall
.
S_IFMT
)
==
syscall
.
S_IFBLK
}
func
(
dir
*
Dir
)
IsRegular
()
bool
{
return
(
dir
.
Mode
&
syscall
.
S_IFMT
)
==
syscall
.
S_IFREG
}
func
(
dir
*
Dir
)
IsSymlink
()
bool
{
return
(
dir
.
Mode
&
syscall
.
S_IFMT
)
==
syscall
.
S_IFLNK
}
func
(
dir
*
Dir
)
IsSocket
()
bool
{
return
(
dir
.
Mode
&
syscall
.
S_IFMT
)
==
syscall
.
S_IFSOCK
}
func
(
dir
*
Dir
)
Permission
()
int
{
return
int
(
dir
.
Mode
&
0777
)
}
src/lib/syscall/types_amd64_darwin.go
View file @
cad7a3ae
...
...
@@ -69,6 +69,25 @@ const (
NAME_MAX
=
255
;
)
// Dir.Mode bits
const
(
S_IFMT
=
0170000
;
/* type of file */
S_IFIFO
=
0010000
;
/* named pipe (fifo) */
S_IFCHR
=
0020000
;
/* character special */
S_IFDIR
=
0040000
;
/* directory */
S_IFBLK
=
0060000
;
/* block special */
S_IFREG
=
0100000
;
/* regular */
S_IFLNK
=
0120000
;
/* symbolic link */
S_IFSOCK
=
0140000
;
/* socket */
S_IFWHT
=
0160000
;
/* whiteout */
S_ISUID
=
0004000
;
/* set user id on execution */
S_ISGID
=
0002000
;
/* set group id on execution */
S_ISVTX
=
0001000
;
/* save swapped text even after use */
S_IRUSR
=
0000400
;
/* read permission, owner */
S_IWUSR
=
0000200
;
/* write permission, owner */
S_IXUSR
=
0000100
;
/* execute/search permission, owner */
)
type
Stat_t
struct
{
Dev
uint32
;
Mode
uint16
;
...
...
src/lib/syscall/types_amd64_linux.go
View file @
cad7a3ae
...
...
@@ -69,6 +69,24 @@ const (
NAME_MAX
=
255
;
)
// Dir.Mode bits
const
(
S_IFMT
=
0170000
;
/* type of file */
S_IFIFO
=
0010000
;
/* named pipe (fifo) */
S_IFCHR
=
0020000
;
/* character special */
S_IFDIR
=
0040000
;
/* directory */
S_IFBLK
=
0060000
;
/* block special */
S_IFREG
=
0100000
;
/* regular */
S_IFLNK
=
0120000
;
/* symbolic link */
S_IFSOCK
=
0140000
;
/* socket */
S_ISUID
=
0004000
;
/* set user id on execution */
S_ISGID
=
0002000
;
/* set group id on execution */
S_ISVTX
=
0001000
;
/* save swapped text even after use */
S_IRUSR
=
0000400
;
/* read permission, owner */
S_IWUSR
=
0000200
;
/* write permission, owner */
S_IXUSR
=
0000100
;
/* execute/search permission, owner */
)
type
Stat_t
struct
{
Dev
uint64
;
Ino
uint64
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment