os.filelock: compile without warnings with gcc on windows

This commit is contained in:
Delyan Angelov 2025-04-23 07:50:15 +03:00
parent b76b1ee763
commit 87d3a1d272
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED
2 changed files with 5 additions and 5 deletions

View file

@ -5,7 +5,7 @@ import time
pub struct FileLock {
name string
mut:
fd int
fd i64
}
pub fn new(fileName string) FileLock {

View file

@ -21,15 +21,15 @@ pub fn (mut l FileLock) acquire() ! {
if fd == -1 {
return error_with_code('cannot create lock file ${l.name}', -1)
}
l.fd = int(fd)
l.fd = fd
}
fn open(f string) voidptr {
fn open(f string) i64 {
f_wide := f.to_wide()
// locking it
fd := C.CreateFileW(f_wide, C.GENERIC_READ | C.GENERIC_WRITE, 0, 0, C.OPEN_ALWAYS,
C.FILE_ATTRIBUTE_NORMAL, 0)
return fd
return i64(fd)
}
pub fn (mut l FileLock) try_acquire() bool {
@ -41,6 +41,6 @@ pub fn (mut l FileLock) try_acquire() bool {
if fd == -1 {
return false
}
l.fd = int(fd)
l.fd = fd
return true
}