2024-08-25 04:08:24 +00:00
|
|
|
package qt
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
#include "gen_qlockfile.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
2024-09-14 22:29:05 +00:00
|
|
|
"runtime"
|
2024-08-25 04:08:24 +00:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
type QLockFile__LockError int
|
|
|
|
|
|
|
|
const (
|
2024-09-20 07:13:26 +00:00
|
|
|
QLockFile__NoError QLockFile__LockError = 0
|
|
|
|
QLockFile__LockFailedError QLockFile__LockError = 1
|
|
|
|
QLockFile__PermissionError QLockFile__LockError = 2
|
|
|
|
QLockFile__UnknownError QLockFile__LockError = 3
|
2024-09-04 06:54:22 +00:00
|
|
|
)
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
type QLockFile struct {
|
2024-11-19 06:29:06 +00:00
|
|
|
h *C.QLockFile
|
|
|
|
isSubclass bool
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QLockFile) cPointer() *C.QLockFile {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return this.h
|
|
|
|
}
|
|
|
|
|
2024-10-16 05:07:56 +00:00
|
|
|
func (this *QLockFile) UnsafePointer() unsafe.Pointer {
|
|
|
|
if this == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return unsafe.Pointer(this.h)
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// newQLockFile constructs the type using only CGO pointers.
|
2024-08-25 04:08:24 +00:00
|
|
|
func newQLockFile(h *C.QLockFile) *QLockFile {
|
2024-09-01 02:23:55 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-08-25 04:08:24 +00:00
|
|
|
return &QLockFile{h: h}
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
// UnsafeNewQLockFile constructs the type using only unsafe pointers.
|
2024-10-16 05:07:56 +00:00
|
|
|
func UnsafeNewQLockFile(h unsafe.Pointer) *QLockFile {
|
2024-11-19 06:29:06 +00:00
|
|
|
if h == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &QLockFile{h: (*C.QLockFile)(h)}
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewQLockFile constructs a new QLockFile object.
|
|
|
|
func NewQLockFile(fileName string) *QLockFile {
|
2024-10-18 23:53:33 +00:00
|
|
|
fileName_ms := C.struct_miqt_string{}
|
|
|
|
fileName_ms.data = C.CString(fileName)
|
|
|
|
fileName_ms.len = C.size_t(len(fileName))
|
|
|
|
defer C.free(unsafe.Pointer(fileName_ms.data))
|
2024-11-19 06:29:06 +00:00
|
|
|
var outptr_QLockFile *C.QLockFile = nil
|
|
|
|
|
|
|
|
C.QLockFile_new(fileName_ms, &outptr_QLockFile)
|
|
|
|
ret := newQLockFile(outptr_QLockFile)
|
|
|
|
ret.isSubclass = true
|
|
|
|
return ret
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QLockFile) Lock() bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QLockFile_Lock(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QLockFile) TryLock() bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QLockFile_TryLock(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QLockFile) Unlock() {
|
|
|
|
C.QLockFile_Unlock(this.h)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QLockFile) SetStaleLockTime(staleLockTime int) {
|
|
|
|
C.QLockFile_SetStaleLockTime(this.h, (C.int)(staleLockTime))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QLockFile) StaleLockTime() int {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (int)(C.QLockFile_StaleLockTime(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QLockFile) IsLocked() bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QLockFile_IsLocked(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (this *QLockFile) RemoveStaleLockFile() bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QLockFile_RemoveStaleLockFile(this.h))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-04 06:54:22 +00:00
|
|
|
func (this *QLockFile) Error() QLockFile__LockError {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (QLockFile__LockError)(C.QLockFile_Error(this.h))
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QLockFile) TryLock1(timeout int) bool {
|
2024-09-17 07:30:27 +00:00
|
|
|
return (bool)(C.QLockFile_TryLock1(this.h, (C.int)(timeout)))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-09-14 22:29:05 +00:00
|
|
|
// Delete this object from C++ memory.
|
2024-08-25 04:08:24 +00:00
|
|
|
func (this *QLockFile) Delete() {
|
2024-11-19 06:29:06 +00:00
|
|
|
C.QLockFile_Delete(this.h, C.bool(this.isSubclass))
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
2024-09-14 22:29:05 +00:00
|
|
|
|
|
|
|
// GoGC adds a Go Finalizer to this pointer, so that it will be deleted
|
|
|
|
// from C++ memory once it is unreachable from Go memory.
|
|
|
|
func (this *QLockFile) GoGC() {
|
|
|
|
runtime.SetFinalizer(this, func(this *QLockFile) {
|
|
|
|
this.Delete()
|
|
|
|
runtime.KeepAlive(this.h)
|
|
|
|
})
|
|
|
|
}
|