diff --git a/os/_posix.vp b/os/_posix.vp index 8e9b041..268130d 100644 --- a/os/_posix.vp +++ b/os/_posix.vp @@ -20,10 +20,10 @@ def _stat(path: str) -> posix.Stat*: """Call stat and return a Stat struct pointer. Return None on failure. Note: the Stat struct is allocated via _mbuddy; the caller must free it.""" st: posix.Stat = posix.Stat() - result: INT = posix.stat(path, t.CPtr(&st)) + result: INT = posix.stat(path, &st) if result != 0: return None - return t.CPtr(&st) + return &st def exists(path: str) -> bool: @@ -37,7 +37,7 @@ def exists(path: str) -> bool: def isdir(path: str) -> bool: """Check whether the path is a directory""" st: posix.Stat = posix.Stat() - result: INT = posix.stat(path, t.CPtr(&st)) + result: INT = posix.stat(path, &st) if result != 0: return False if posix.S_ISDIR(st.st_mode): @@ -48,7 +48,7 @@ def isdir(path: str) -> bool: def isfile(path: str) -> bool: """Check whether the path is a regular file""" st: posix.Stat = posix.Stat() - result: INT = posix.stat(path, t.CPtr(&st)) + result: INT = posix.stat(path, &st) if result != 0: return False if posix.S_ISREG(st.st_mode): @@ -59,7 +59,7 @@ def isfile(path: str) -> bool: def getsize(path: str) -> int64: """Return the file size in bytes. Return -1 on failure.""" st: posix.Stat = posix.Stat() - result: INT = posix.stat(path, t.CPtr(&st)) + result: INT = posix.stat(path, &st) if result != 0: return -1 return st.st_size diff --git a/os/_win32.vp b/os/_win32.vp index f778bf6..8798c26 100644 --- a/os/_win32.vp +++ b/os/_win32.vp @@ -62,7 +62,7 @@ def getsize(path: str) -> int64: if handle == w32.win32base.INVALID_HANDLE_VALUE: return -1 li: w32.win32base.LARGE_INTEGER = w32.win32base.LARGE_INTEGER() - result: BOOL = w32.win32file.GetFileSizeEx(handle, t.CPtr(&li)) + result: BOOL = w32.win32file.GetFileSizeEx(handle, &li) w32.win32base.CloseHandle(handle) if result == 0: return -1 @@ -193,7 +193,7 @@ def listdir(path: str, out_names: str*, max_count: ULONG) -> ULONG: pattern[i] = 0 find_data: w32.win32file.WIN32_FIND_DATAA = w32.win32file.WIN32_FIND_DATAA() - handle: w32.win32base.HANDLE = w32.win32file.FindFirstFileA(pattern, t.CPtr(&find_data)) + handle: w32.win32base.HANDLE = w32.win32file.FindFirstFileA(pattern, &find_data) if handle == w32.win32base.INVALID_HANDLE_VALUE: return 0 @@ -204,12 +204,12 @@ def listdir(path: str, out_names: str*, max_count: ULONG) -> ULONG: if name[0] == '.': if name[1] == 0: # "." - if w32.win32file.FindNextFileA(handle, t.CPtr(&find_data)) == 0: + if w32.win32file.FindNextFileA(handle, &find_data) == 0: break continue if name[1] == '.' and name[2] == 0: # ".." - if w32.win32file.FindNextFileA(handle, t.CPtr(&find_data)) == 0: + if w32.win32file.FindNextFileA(handle, &find_data) == 0: break continue @@ -225,7 +225,7 @@ def listdir(path: str, out_names: str*, max_count: ULONG) -> ULONG: out_names[count] = str(name_buf) count += 1 - if w32.win32file.FindNextFileA(handle, t.CPtr(&find_data)) == 0: + if w32.win32file.FindNextFileA(handle, &find_data) == 0: break w32.win32file.FindClose(handle) diff --git a/shutil.vp b/shutil.vp index 7b5f60b..2a4e2d0 100644 --- a/shutil.vp +++ b/shutil.vp @@ -91,7 +91,7 @@ def _copy_posix(src: str, dst: str) -> int: if result != 0: return -1 st: posix.Stat = posix.Stat() - if posix.stat(src, t.CPtr(&st)) == 0: + if posix.stat(src, &st) == 0: posix.chmod(dst, st.st_mode) return 0 @@ -127,7 +127,7 @@ def _rmtree_win32(path: str) -> int: pattern[i] = 0 find_data: w32.win32file.WIN32_FIND_DATAA = w32.win32file.WIN32_FIND_DATAA() - handle: w32.win32base.HANDLE = w32.win32file.FindFirstFileA(pattern, t.CPtr(&find_data)) + handle: w32.win32base.HANDLE = w32.win32file.FindFirstFileA(pattern, &find_data) _mbuddy.free(pattern) if handle == w32.win32base.INVALID_HANDLE_VALUE: return -1 @@ -174,7 +174,7 @@ def _rmtree_win32(path: str) -> int: result = -1 _mbuddy.free(full_path) # Continue searching next entry - if w32.win32file.FindNextFileA(handle, t.CPtr(&find_data)) == 0: + if w32.win32file.FindNextFileA(handle, &find_data) == 0: has_more = 0 w32.win32file.FindClose(handle) diff --git a/subprocess.vp b/subprocess.vp index 9a105ae..21fbf61 100644 --- a/subprocess.vp +++ b/subprocess.vp @@ -173,7 +173,7 @@ def _run_win32(args: str, capture_output: bool, text: bool) -> CompletedProcess* # Get exit code exit_code: ULONG = 0 - w32.win32process.GetExitCodeProcess(pi.hProcess, t.CPtr(&exit_code)) + w32.win32process.GetExitCodeProcess(pi.hProcess, &exit_code) # Close handles w32.win32base.CloseHandle(pi.hProcess) diff --git a/w32/fileio.vp b/w32/fileio.vp index ddc1ea4..56f810e 100644 --- a/w32/fileio.vp +++ b/w32/fileio.vp @@ -180,7 +180,7 @@ class File: if self.closed: return FRESULT.ERR_CLOSED if not self.can_read: return FRESULT.ERR_PERM bytes_read: ULONG = 0 - result: BOOL = w32.win32file.ReadFile(self.handle, buf, count, t.CPtr(&bytes_read), None) + result: BOOL = w32.win32file.ReadFile(self.handle, buf, count, &bytes_read, None) if result == 0: return FRESULT.ERR_IO return LONG(bytes_read) @@ -226,7 +226,7 @@ class File: def size(self) -> LONGLONG: if self.closed: return -1 li: w32.win32base.LARGE_INTEGER = w32.win32base.LARGE_INTEGER() - result: BOOL = w32.win32file.GetFileSizeEx(self.handle, t.CPtr(&li)) + result: BOOL = w32.win32file.GetFileSizeEx(self.handle, &li) if result == 0: return -1 return li.QuadPart @@ -239,7 +239,7 @@ class File: ch: int = 0 while total < max_count - 1: bytes_read = 0 - result: BOOL = w32.win32file.ReadFile(self.handle, buf + total, 1, t.CPtr(&bytes_read), None) + result: BOOL = w32.win32file.ReadFile(self.handle, buf + total, 1, &bytes_read, None) if result == 0 or bytes_read == 0: break # Explicit byte read: indexing loads 1 byte by the pointer element type (i8), same as Repl.vp _read_line. # Do not use c.Deref(buf + total): its width depends on whether the pointer is i8*, but 1 byte is required here. @@ -265,7 +265,7 @@ class File: to_read = buf_size - 1 self.seek(0, SEEK_SET) bytes_read: ULONG = 0 - result: BOOL = w32.win32file.ReadFile(self.handle, buf, to_read, t.CPtr(&bytes_read), None) + result: BOOL = w32.win32file.ReadFile(self.handle, buf, to_read, &bytes_read, None) if result == 0: return FRESULT.ERR_IO if bytes_read < buf_size: buf[bytes_read] = 0 @@ -357,7 +357,7 @@ class FileW: if self.closed: return FRESULT.ERR_CLOSED if not self.can_read: return FRESULT.ERR_PERM bytes_read: ULONG = 0 - result: BOOL = w32.win32file.ReadFile(self.handle, buf, count, t.CPtr(&bytes_read), None) + result: BOOL = w32.win32file.ReadFile(self.handle, buf, count, &bytes_read, None) if result == 0: return FRESULT.ERR_IO return LONG(bytes_read) @@ -365,7 +365,7 @@ class FileW: if self.closed: return FRESULT.ERR_CLOSED if not self.can_write: return FRESULT.ERR_PERM bytes_written: ULONG = 0 - result: BOOL = w32.win32file.WriteFile(self.handle, buf, count, t.CPtr(&bytes_written), None) + result: BOOL = w32.win32file.WriteFile(self.handle, buf, count, &bytes_written, None) if result == 0: return FRESULT.ERR_IO return LONG(bytes_written) @@ -403,7 +403,7 @@ class FileW: def size(self) -> LONGLONG: if self.closed: return -1 li: w32.win32base.LARGE_INTEGER = w32.win32base.LARGE_INTEGER() - result: BOOL = w32.win32file.GetFileSizeEx(self.handle, t.CPtr(&li)) + result: BOOL = w32.win32file.GetFileSizeEx(self.handle, &li) if result == 0: return -1 return li.QuadPart @@ -416,7 +416,7 @@ class FileW: ch: int = 0 while total < max_count - 1: bytes_read = 0 - result: BOOL = w32.win32file.ReadFile(self.handle, buf + total, 1, t.CPtr(&bytes_read), None) + result: BOOL = w32.win32file.ReadFile(self.handle, buf + total, 1, &bytes_read, None) if result == 0 or bytes_read == 0: break # Explicit byte read: indexing loads 1 byte by the pointer element type (i8), same as Repl.vp _read_line. # Do not use c.Deref(buf + total): its width depends on whether the pointer is i8*, but 1 byte is required here. @@ -442,7 +442,7 @@ class FileW: to_read = buf_size - 1 self.seek(0, SEEK_SET) bytes_read: ULONG = 0 - result: BOOL = w32.win32file.ReadFile(self.handle, buf, to_read, t.CPtr(&bytes_read), None) + result: BOOL = w32.win32file.ReadFile(self.handle, buf, to_read, &bytes_read, None) if result == 0: return FRESULT.ERR_IO if bytes_read < buf_size: buf[bytes_read] = 0