Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f9f0ffa

Browse files
committed
cmd/gomobile: reset readonly bits of downloaded files in Windows
os.Rename in init fails in Windows for various reasons. One of them is the temporary files extracted from NDK, OpenAL archives. For some reason, some of them have read-only properties. (golang/go#12212) > gomobile init gomobile: rename C:\Users\foo\pkg\gomobile\work-427911983\openal\include\AL C:\Users\foo\pkg\gomobile\android-ndk-r10e\arm\sysroot\usr\include\AL: Access is denied. We reset the read-only bits of all the extracted files. Change-Id: Ib958cbedf1b7527ecb5b9318f23fe9437dc7c241 Reviewed-on: https://go-review.googlesource.com/12970 Reviewed-by: David Crawshaw <[email protected]>
1 parent f4bcb3c commit f9f0ffa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cmd/gomobile/init.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func move(dst, src string, names ...string) error {
223223
}
224224
if goos == "windows" {
225225
// os.Rename fails if dstf already exists.
226-
os.Remove(dstf)
226+
removeAll(dstf)
227227
}
228228
if err := os.Rename(srcf, dstf); err != nil {
229229
return err
@@ -291,6 +291,9 @@ func fetchOpenAL() error {
291291
if err := extract("openal", archive); err != nil {
292292
return err
293293
}
294+
if goos == "windows" {
295+
resetReadOnlyFlagAll(filepath.Join(tmpdir, "openal"))
296+
}
294297
dst := filepath.Join(ndkccpath, "arm", "sysroot", "usr", "include")
295298
src := filepath.Join(tmpdir, "openal", "include")
296299
if err := move(dst, src, "AL"); err != nil {
@@ -366,6 +369,9 @@ func fetchNDK() error {
366369
return err
367370
}
368371
}
372+
if goos == "windows" {
373+
resetReadOnlyFlagAll(filepath.Join(tmpdir, "android-"+ndkVersion))
374+
}
369375

370376
dst := filepath.Join(ndkccpath, "arm")
371377
dstSysroot := filepath.Join(dst, "sysroot/usr")

0 commit comments

Comments
 (0)