-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03b8cfd
commit fefd643
Showing
6 changed files
with
82 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package utils | ||
|
||
import "os" | ||
|
||
func CreateLink(path string, lnk string) error { | ||
return os.Symlink(path, lnk) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package utils | ||
|
||
/* | ||
#cgo CPPFLAGS: -DUNICODE=1 | ||
#cgo windows LDFLAGS: -luuid -lole32 -loleaut32 | ||
#include <stdlib.h> | ||
int CreateSymLink(const char* path, const char* sympath); | ||
*/ | ||
import "C" | ||
import ( | ||
"fmt" | ||
"unsafe" | ||
) | ||
|
||
func CreateLink(path string, lnk string) error { | ||
cpath := C.CString(path) | ||
clnk := C.CString(lnk) | ||
defer C.free(unsafe.Pointer(cpath)) | ||
defer C.free(unsafe.Pointer(clnk)) | ||
hr := C.CreateSymLink(cpath, clnk) | ||
if hr != 0 { | ||
return fmt.Errorf("failed to create link: hresult = %d", hr) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters