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
a54cbcec
Commit
a54cbcec
authored
Feb 16, 2011
by
Yasuhiro Matsumoto
Committed by
Alex Brainman
Feb 16, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
syscall: implement chmod() for win32.
R=golang-dev, rsc, brainman CC=golang-dev
https://golang.org/cl/4175049
parent
074354c2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
5 deletions
+42
-5
syscall_windows.go
src/pkg/syscall/syscall_windows.go
+26
-5
zsyscall_windows_386.go
src/pkg/syscall/zsyscall_windows_386.go
+15
-0
ztypes_windows_386.go
src/pkg/syscall/ztypes_windows_386.go
+1
-0
No files found.
src/pkg/syscall/syscall_windows.go
View file @
a54cbcec
...
...
@@ -154,6 +154,7 @@ func NewCallback(fn interface{}) uintptr
//sys SetEnvironmentVariable(name *uint16, value *uint16) (errno int) = kernel32.SetEnvironmentVariableW
//sys SetFileTime(handle int32, ctime *Filetime, atime *Filetime, wtime *Filetime) (errno int)
//sys GetFileAttributes(name *uint16) (attrs uint32, errno int) [failretval==INVALID_FILE_ATTRIBUTES] = kernel32.GetFileAttributesW
//sys SetFileAttributes(name *uint16, attrs uint32) (errno int) [failretval==INVALID_FILE_ATTRIBUTES] = kernel32.SetFileAttributesW
//sys GetCommandLine() (cmd *uint16) = kernel32.GetCommandLineW
//sys CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, errno int) [failretval==nil] = shell32.CommandLineToArgvW
//sys LocalFree(hmem uint32) (handle uint32, errno int) [failretval!=0]
...
...
@@ -718,11 +719,31 @@ func Fchdir(fd int) (errno int) { return EWINDOWS }
func
Link
(
oldpath
,
newpath
string
)
(
errno
int
)
{
return
EWINDOWS
}
func
Symlink
(
path
,
link
string
)
(
errno
int
)
{
return
EWINDOWS
}
func
Readlink
(
path
string
,
buf
[]
byte
)
(
n
int
,
errno
int
)
{
return
0
,
EWINDOWS
}
func
Chmod
(
path
string
,
mode
uint32
)
(
errno
int
)
{
return
EWINDOWS
}
func
Fchmod
(
fd
int
,
mode
uint32
)
(
errno
int
)
{
return
EWINDOWS
}
func
Chown
(
path
string
,
uid
int
,
gid
int
)
(
errno
int
)
{
return
EWINDOWS
}
func
Lchown
(
path
string
,
uid
int
,
gid
int
)
(
errno
int
)
{
return
EWINDOWS
}
func
Fchown
(
fd
int
,
uid
int
,
gid
int
)
(
errno
int
)
{
return
EWINDOWS
}
func
Chmod
(
path
string
,
mode
uint32
)
(
errno
int
)
{
attrs
,
errno
:=
GetFileAttributes
(
StringToUTF16Ptr
(
path
))
if
errno
!=
0
{
return
}
if
mode
==
0
{
return
EINVAL
}
if
mode
&
S_IWRITE
!=
0
{
attrs
&^=
FILE_ATTRIBUTE_READONLY
}
else
if
attrs
&
FILE_ATTRIBUTE_READONLY
==
0
{
attrs
|=
FILE_ATTRIBUTE_READONLY
}
errno
=
SetFileAttributes
(
StringToUTF16Ptr
(
path
),
attrs
)
return
}
func
Fchmod
(
fd
int
,
mode
uint32
)
(
errno
int
)
{
return
EWINDOWS
}
func
Chown
(
path
string
,
uid
int
,
gid
int
)
(
errno
int
)
{
return
EWINDOWS
}
func
Lchown
(
path
string
,
uid
int
,
gid
int
)
(
errno
int
)
{
return
EWINDOWS
}
func
Fchown
(
fd
int
,
uid
int
,
gid
int
)
(
errno
int
)
{
return
EWINDOWS
}
func
Getuid
()
(
uid
int
)
{
return
-
1
}
func
Geteuid
()
(
euid
int
)
{
return
-
1
}
...
...
src/pkg/syscall/zsyscall_windows_386.go
View file @
a54cbcec
...
...
@@ -63,6 +63,7 @@ var (
procSetEnvironmentVariableW
=
getSysProcAddr
(
modkernel32
,
"SetEnvironmentVariableW"
)
procSetFileTime
=
getSysProcAddr
(
modkernel32
,
"SetFileTime"
)
procGetFileAttributesW
=
getSysProcAddr
(
modkernel32
,
"GetFileAttributesW"
)
procSetFileAttributesW
=
getSysProcAddr
(
modkernel32
,
"SetFileAttributesW"
)
procGetCommandLineW
=
getSysProcAddr
(
modkernel32
,
"GetCommandLineW"
)
procCommandLineToArgvW
=
getSysProcAddr
(
modshell32
,
"CommandLineToArgvW"
)
procLocalFree
=
getSysProcAddr
(
modkernel32
,
"LocalFree"
)
...
...
@@ -806,6 +807,20 @@ func GetFileAttributes(name *uint16) (attrs uint32, errno int) {
return
}
func
SetFileAttributes
(
name
*
uint16
,
attrs
uint32
)
(
errno
int
)
{
r0
,
_
,
e1
:=
Syscall
(
procSetFileAttributesW
,
2
,
uintptr
(
unsafe
.
Pointer
(
name
)),
uintptr
(
attrs
),
0
)
if
int
(
r0
)
==
0
{
if
e1
!=
0
{
errno
=
int
(
e1
)
}
else
{
errno
=
EINVAL
}
}
else
{
errno
=
0
}
return
}
func
GetCommandLine
()
(
cmd
*
uint16
)
{
r0
,
_
,
_
:=
Syscall
(
procGetCommandLineW
,
0
,
0
,
0
,
0
)
cmd
=
(
*
uint16
)(
unsafe
.
Pointer
(
r0
))
...
...
src/pkg/syscall/ztypes_windows_386.go
View file @
a54cbcec
...
...
@@ -380,6 +380,7 @@ const (
S_ISGID
=
0x400
S_ISVTX
=
0x200
S_IRUSR
=
0x100
S_IWRITE
=
0x80
S_IWUSR
=
0x80
S_IXUSR
=
0x40
)
...
...
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