miqt/qt6/gen_qlockfile.cpp

73 lines
1.6 KiB
C++
Raw Normal View History

2024-10-20 18:21:03 +13:00
#include <QLockFile>
#include <QString>
#include <QByteArray>
#include <cstring>
#include <qlockfile.h>
#include "gen_qlockfile.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* extern C */
#endif
2024-10-20 18:21:03 +13:00
2024-12-07 17:15:57 +13:00
QLockFile* QLockFile_new(struct miqt_string fileName) {
2024-10-20 18:21:03 +13:00
QString fileName_QString = QString::fromUtf8(fileName.data, fileName.len);
2024-12-07 17:15:57 +13:00
return new QLockFile(fileName_QString);
2024-10-20 18:21:03 +13:00
}
2025-02-01 13:45:16 +13:00
struct miqt_string QLockFile_fileName(const QLockFile* self) {
2024-10-20 18:21:03 +13:00
QString _ret = self->fileName();
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _b = _ret.toUtf8();
struct miqt_string _ms;
_ms.len = _b.length();
_ms.data = static_cast<char*>(malloc(_ms.len));
memcpy(_ms.data, _b.data(), _ms.len);
return _ms;
}
2025-02-01 13:45:16 +13:00
bool QLockFile_lock(QLockFile* self) {
2024-10-20 18:21:03 +13:00
return self->lock();
}
2025-02-01 13:45:16 +13:00
bool QLockFile_tryLock(QLockFile* self) {
2024-10-20 18:21:03 +13:00
return self->tryLock();
}
2025-02-01 13:45:16 +13:00
void QLockFile_unlock(QLockFile* self) {
2024-10-20 18:21:03 +13:00
self->unlock();
}
2025-02-01 13:45:16 +13:00
void QLockFile_setStaleLockTime(QLockFile* self, int staleLockTime) {
2024-10-20 18:21:03 +13:00
self->setStaleLockTime(static_cast<int>(staleLockTime));
}
2025-02-01 13:45:16 +13:00
int QLockFile_staleLockTime(const QLockFile* self) {
2024-10-20 18:21:03 +13:00
return self->staleLockTime();
}
2025-02-01 13:45:16 +13:00
bool QLockFile_isLocked(const QLockFile* self) {
2024-10-20 18:21:03 +13:00
return self->isLocked();
}
2025-02-01 13:45:16 +13:00
bool QLockFile_removeStaleLockFile(QLockFile* self) {
2024-10-20 18:21:03 +13:00
return self->removeStaleLockFile();
}
2025-02-01 13:45:16 +13:00
int QLockFile_error(const QLockFile* self) {
2024-10-20 18:21:03 +13:00
QLockFile::LockError _ret = self->error();
return static_cast<int>(_ret);
}
2025-02-01 13:45:16 +13:00
bool QLockFile_tryLock1(QLockFile* self, int timeout) {
2024-10-20 18:21:03 +13:00
return self->tryLock(static_cast<int>(timeout));
}
2025-02-01 13:45:16 +13:00
void QLockFile_delete(QLockFile* self) {
delete self;
2024-10-20 18:21:03 +13:00
}