00001 #ifndef CLASSLIB_FILE_LOCK_H
00002 # define CLASSLIB_FILE_LOCK_H
00003
00004
00005
00006 # include "classlib/sysapi/IOTypes.h"
00007
00008 namespace lat {
00009
00010
00011
00012
00013 class File;
00014
00015
00016
00017
00018
00019 class FileLock
00020 {
00021 public:
00022 FileLock (void);
00023 FileLock (File *file, IOOffset pos, IOOffset len,
00024 bool write = true, bool wait = false);
00025 ~FileLock (void);
00026
00027 void lock (File *file,
00028 IOOffset pos,
00029 IOOffset length,
00030 bool write = true,
00031 bool wait = false);
00032 void unlock (void);
00033 static bool locked (File *file,
00034 IOOffset pos,
00035 IOOffset length,
00036 bool write = true);
00037
00038 private:
00039 static void unlock (File *file, IOOffset pos, IOOffset length);
00040
00041 File *m_file;
00042 IOOffset m_offset;
00043 IOOffset m_length;
00044
00045
00046 FileLock (const FileLock &);
00047 FileLock &operator= (const FileLock &);
00048 };
00049
00050
00051
00052
00053 }
00054 #endif // CLASSLIB_FILE_LOCK_H