2024-08-25 04:08:24 +00:00
|
|
|
#include <QLockFile>
|
|
|
|
#include <QString>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <cstring>
|
|
|
|
#include "qlockfile.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "gen_qlockfile.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
extern void miqt_exec_callback(void* cb, int argc, void* argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
QLockFile* QLockFile_new(const char* fileName, size_t fileName_Strlen) {
|
|
|
|
QString fileName_QString = QString::fromUtf8(fileName, fileName_Strlen);
|
|
|
|
return new QLockFile(fileName_QString);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QLockFile_Lock(QLockFile* self) {
|
|
|
|
return self->lock();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QLockFile_TryLock(QLockFile* self) {
|
|
|
|
return self->tryLock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QLockFile_Unlock(QLockFile* self) {
|
|
|
|
self->unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QLockFile_SetStaleLockTime(QLockFile* self, int staleLockTime) {
|
|
|
|
self->setStaleLockTime(static_cast<int>(staleLockTime));
|
|
|
|
}
|
|
|
|
|
|
|
|
int QLockFile_StaleLockTime(QLockFile* self) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return const_cast<const QLockFile*>(self)->staleLockTime();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool QLockFile_IsLocked(QLockFile* self) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return const_cast<const QLockFile*>(self)->isLocked();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool QLockFile_RemoveStaleLockFile(QLockFile* self) {
|
|
|
|
return self->removeStaleLockFile();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
uintptr_t QLockFile_Error(QLockFile* self) {
|
|
|
|
QLockFile::LockError ret = const_cast<const QLockFile*>(self)->error();
|
|
|
|
return static_cast<uintptr_t>(ret);
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
bool QLockFile_TryLock1(QLockFile* self, int timeout) {
|
|
|
|
return self->tryLock(static_cast<int>(timeout));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QLockFile_Delete(QLockFile* self) {
|
|
|
|
delete self;
|
|
|
|
}
|
|
|
|
|