📄 filelock.cpp
字号:
/*************************************************************************** filelock.cpp - description ------------------- begin : Fri Jul 20 2001 copyright : (C) 2001 by Mark email : alben@yeah.net ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#include <errno.h>#include <sys/types.h>#include <sys/stat.h>#include "filelock.h"CFileLock::CFileLock(const char* sPath){ if ((m_iFd = open(sPath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0) throw CFileLockException(strerror(errno), __FILE__, __LINE__);}CFileLock::~CFileLock(){ close(m_iFd);}bool CFileLock::Fcntl(int iCmd, int iType, int iOffset, int iLen, int iWhence){ struct flock stLock; stLock.l_type = iType; stLock.l_start = iOffset; stLock.l_whence = iWhence; stLock.l_len = iLen; if (fcntl(m_iFd, iCmd, &stLock) < 0) { if (errno == EINTR) return false; throw CFileLockException(strerror(errno), __FILE__, __LINE__); } return true;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -