summaryrefslogtreecommitdiff
path: root/libraries/LocalPeer/src/LockedFile_unix.cpp
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 17:36:40 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 17:36:40 +0300
commit1d4bf6e8b1208383021e22f61d859e9b721c482d (patch)
tree21c8e0c4350d7c44d817243ebf409be625ea4f21 /libraries/LocalPeer/src/LockedFile_unix.cpp
parent38c57e163abad6216f7e0f44d401c362c5fd5da6 (diff)
downloadProject-Tick-1d4bf6e8b1208383021e22f61d859e9b721c482d.tar.gz
Project-Tick-1d4bf6e8b1208383021e22f61d859e9b721c482d.zip
NOISSUE reformat MeshMC to new clang format rules and fixed macOS portability issue and java find issue
Signed-off-by: Mehmet Samet Duman <yongdohyun@projecttick.org>
Diffstat (limited to 'libraries/LocalPeer/src/LockedFile_unix.cpp')
-rw-r--r--libraries/LocalPeer/src/LockedFile_unix.cpp110
1 files changed, 54 insertions, 56 deletions
diff --git a/libraries/LocalPeer/src/LockedFile_unix.cpp b/libraries/LocalPeer/src/LockedFile_unix.cpp
index 9f8142844e..10041c0f80 100644
--- a/libraries/LocalPeer/src/LockedFile_unix.cpp
+++ b/libraries/LocalPeer/src/LockedFile_unix.cpp
@@ -47,68 +47,66 @@
bool LockedFile::lock(LockMode mode, bool block)
{
- if (!isOpen()) {
- qWarning("QtLockedFile::lock(): file is not opened");
- return false;
- }
-
- if (mode == NoLock)
- return unlock();
-
- if (mode == m_lock_mode)
- return true;
-
- if (m_lock_mode != NoLock)
- unlock();
-
- struct flock fl;
- fl.l_whence = SEEK_SET;
- fl.l_start = 0;
- fl.l_len = 0;
- fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK;
- int cmd = block ? F_SETLKW : F_SETLK;
- int ret = fcntl(handle(), cmd, &fl);
-
- if (ret == -1) {
- if (errno != EINTR && errno != EAGAIN)
- qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
- return false;
- }
-
-
- m_lock_mode = mode;
- return true;
+ if (!isOpen()) {
+ qWarning("QtLockedFile::lock(): file is not opened");
+ return false;
+ }
+
+ if (mode == NoLock)
+ return unlock();
+
+ if (mode == m_lock_mode)
+ return true;
+
+ if (m_lock_mode != NoLock)
+ unlock();
+
+ struct flock fl;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK;
+ int cmd = block ? F_SETLKW : F_SETLK;
+ int ret = fcntl(handle(), cmd, &fl);
+
+ if (ret == -1) {
+ if (errno != EINTR && errno != EAGAIN)
+ qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
+ return false;
+ }
+
+ m_lock_mode = mode;
+ return true;
}
-
bool LockedFile::unlock()
{
- if (!isOpen()) {
- qWarning("QtLockedFile::unlock(): file is not opened");
- return false;
- }
-
- if (!isLocked())
- return true;
-
- struct flock fl;
- fl.l_whence = SEEK_SET;
- fl.l_start = 0;
- fl.l_len = 0;
- fl.l_type = F_UNLCK;
- int ret = fcntl(handle(), F_SETLKW, &fl);
-
- if (ret == -1) {
- qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
- return false;
- }
-
- m_lock_mode = NoLock;
- return true;
+ if (!isOpen()) {
+ qWarning("QtLockedFile::unlock(): file is not opened");
+ return false;
+ }
+
+ if (!isLocked())
+ return true;
+
+ struct flock fl;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 0;
+ fl.l_type = F_UNLCK;
+ int ret = fcntl(handle(), F_SETLKW, &fl);
+
+ if (ret == -1) {
+ qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
+ return false;
+ }
+
+ m_lock_mode = NoLock;
+ return true;
}
LockedFile::~LockedFile()
{
- if (isOpen())
- unlock();
+ if (isOpen())
+ unlock();
}