Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1092)

Delta Between Two Patch Sets: src/pkg/os/executable_windows.go

Issue 6736069: code review 6736069: runtime, syscall, os: add os.ExecPath() (string, error)
Left Patch Set: diff -r 88c4bdf6cfb8 https://code.google.com/p/go/ Created 11 years, 5 months ago
Right Patch Set: diff -r 617db9efbdf1 https://code.google.com/p/go/ Created 11 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/os/executable_test.go ('k') | src/pkg/runtime/executable_darwin.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2012 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 )
10
11 func getModuleFileName(handle syscall.Handle) (string, error) {
12 n := uint32(1024)
13 var buf []uint16
14 for {
15 buf = make([]uint16, n)
16 r, err := syscall.GetModuleFileName(handle, &buf[0], n)
17 if err != nil {
18 return "", err
19 }
20 if r < n {
21 break
22 }
23 // r == n means n not big enough
24 n += 1024
25 }
26 return syscall.UTF16ToString(buf), nil
27 }
28
29 func executable() (string, error) {
30 return getModuleFileName(0)
31 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b