mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
os.filelock: compile without warnings with gcc on windows
This commit is contained in:
parent
b76b1ee763
commit
87d3a1d272
2 changed files with 5 additions and 5 deletions
|
@ -5,7 +5,7 @@ import time
|
||||||
pub struct FileLock {
|
pub struct FileLock {
|
||||||
name string
|
name string
|
||||||
mut:
|
mut:
|
||||||
fd int
|
fd i64
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(fileName string) FileLock {
|
pub fn new(fileName string) FileLock {
|
||||||
|
|
|
@ -21,15 +21,15 @@ pub fn (mut l FileLock) acquire() ! {
|
||||||
if fd == -1 {
|
if fd == -1 {
|
||||||
return error_with_code('cannot create lock file ${l.name}', -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()
|
f_wide := f.to_wide()
|
||||||
// locking it
|
// locking it
|
||||||
fd := C.CreateFileW(f_wide, C.GENERIC_READ | C.GENERIC_WRITE, 0, 0, C.OPEN_ALWAYS,
|
fd := C.CreateFileW(f_wide, C.GENERIC_READ | C.GENERIC_WRITE, 0, 0, C.OPEN_ALWAYS,
|
||||||
C.FILE_ATTRIBUTE_NORMAL, 0)
|
C.FILE_ATTRIBUTE_NORMAL, 0)
|
||||||
return fd
|
return i64(fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut l FileLock) try_acquire() bool {
|
pub fn (mut l FileLock) try_acquire() bool {
|
||||||
|
@ -41,6 +41,6 @@ pub fn (mut l FileLock) try_acquire() bool {
|
||||||
if fd == -1 {
|
if fd == -1 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
l.fd = int(fd)
|
l.fd = fd
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue