mirror of
https://github.com/golang/go
synced 2024-11-18 17:04:41 -07:00
os: set TMPDIR on darwin/arm
Change-Id: Iee25f4b0a31ece0aae79c68aec809e1e4308f865 Reviewed-on: https://go-review.googlesource.com/6311 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
5f55011aea
commit
87a0d395c3
38
src/os/file_darwin_arm.go
Normal file
38
src/os/file_darwin_arm.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package os
|
||||||
|
|
||||||
|
/*
|
||||||
|
#cgo CFLAGS: -x objective-c
|
||||||
|
#cgo LDFLAGS: -framework CoreFoundation -framework Foundation
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <CoreFoundation/CFString.h>
|
||||||
|
#include <Foundation/NSPathUtilities.h>
|
||||||
|
|
||||||
|
char tmpdir[MAXPATHLEN];
|
||||||
|
|
||||||
|
char* loadtmpdir() {
|
||||||
|
tmpdir[0] = 0;
|
||||||
|
CFStringRef path = (CFStringRef)NSTemporaryDirectory();
|
||||||
|
CFStringGetCString(path, tmpdir, sizeof(tmpdir), kCFStringEncodingUTF8);
|
||||||
|
return tmpdir;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if Getenv("TEMPDIR") != "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dir := C.GoString(C.loadtmpdir())
|
||||||
|
if len(dir) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if dir[len(dir)-1] == '/' {
|
||||||
|
dir = dir[:len(dir)-1]
|
||||||
|
}
|
||||||
|
Setenv("TMPDIR", dir)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user