📄 filelock.h
字号:
/*************************************************************************** filelock.h - 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. * * * ***************************************************************************/#ifndef FILELOCK_H#define FILELOCK_H#include <unistd.h>#include <fcntl.h>#include "tinycxx/exception.h"class CFileLock{protected: int m_iFd; protected: //return false when interupt by singal bool Fcntl(int iCmd, int iType, int iOffset, int iLen, int iWhence); public: CFileLock(const char* sPath); virtual ~CFileLock(); //return false when interupt by singal inline bool ReadLock(int iOffset, int iLen = 1, int iWhence = SEEK_SET) { return Fcntl(F_SETLK, F_RDLCK, iOffset, iLen, iWhence); } inline bool WriteLock(int iOffset, int iLen = 1, int iWhence = SEEK_SET) { return Fcntl(F_SETLK, F_WRLCK, iOffset, iLen, iWhence); } inline bool ReadLockW(int iOffset, int iLen = 1, int iWhence = SEEK_SET) { return Fcntl(F_SETLKW, F_RDLCK, iOffset, iLen, iWhence); } inline bool WriteLockW(int iOffset, int iLen = 1, int iWhence = SEEK_SET) { return Fcntl(F_SETLKW, F_WRLCK, iOffset, iLen, iWhence); } inline bool Unlock(int iOffset, int iLen = 1, int iWhence = SEEK_SET) { return Fcntl(F_SETLK, F_UNLCK, iOffset, iLen, iWhence); }};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -