fixed: inability to remove read-only files on Windows
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 11 Dec 2023 18:21:47 +0000 (12:21 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 11 Dec 2023 18:21:47 +0000 (12:21 -0600)
runtime/src/ort_files.h
scripts/onyx-pkg.onyx
shared/include/small_windows.h

index 148454e6a84a43e8e67e1bbfbb543ddf0b7ca0ed..87ec350f17675351dd135e7ab2258c583f3eefcb 100644 (file)
@@ -89,6 +89,12 @@ ONYX_DEF(__file_remove, (WASM_I32, WASM_I32), (WASM_I32)) {
     strncpy(path, path_ptr, path_len);
     path[path_len] = 0;
 
+    #if _BH_WINDOWS
+        DWORD attrs = GetFileAttributesA(path);
+        attrs &= ~FILE_ATTRIBUTE_READONLY;
+        SetFileAttributesA(path, attrs);
+    #endif
+
     results->data[0] = WASM_I32_VAL(bh_file_remove(path));
     return NULL;
 }
index 0159a9267a129eaefb966adc19ea925c42a96be9..508fc18349391ca63aa09887437d54ffaa8d86b6 100644 (file)
@@ -1047,10 +1047,10 @@ Git :: struct {
             }
 
             rolling_parent := make(dyn_str);
-            path := string.split(actual_dest, '/');
+            path := string.split(actual_dest, os.PATH_SEP);
             for path[0 .. path.length-1] {
                 string.append(&rolling_parent, it);
-                string.append(&rolling_parent, "/");
+                string.append(&rolling_parent, os.PATH_SEP);
 
                 if !os.dir_exists(rolling_parent) {
                     os.dir_create(rolling_parent);
index a3c4924af726fd022883fadc6e17f8c48036e6ca..edf5a5e87eed27116363b64d2242097b96ef4d92 100644 (file)
@@ -469,3 +469,6 @@ GB_DLL_IMPORT BOOL WINAPI WaitOnAddress(volatile void * Address, void * compareA
 
 GB_DLL_IMPORT DWORD GetCurrentDirectory(DWORD nBufferLength, char *lpBuffer);
 GB_DLL_IMPORT BOOL  SetCurrentDirectory(char *lpPathName);
+
+GB_DLL_IMPORT DWORD GetFileAttributesA(char *lpPathName);
+GB_DLL_IMPORT BOOL  SetFileAttributesA(char *lpPathName, DWORD attrs);
\ No newline at end of file