forked from Karasiq/MPQ-Repacker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUFileLock.cpp
More file actions
29 lines (29 loc) · 745 Bytes
/
UFileLock.cpp
File metadata and controls
29 lines (29 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//---------------------------------------------------------------------------
#include "UFileLock.h"
#pragma hdrstop
//---------------------------------------------------------------------------
__fastcall TLockedFile::TLockedFile(const UnicodeString FileName)
{
this->File = FileName;
this->Locked = false;
this->hFile = NULL;
}
__fastcall TLockedFile::~TLockedFile()
{
Unlock();
}
void TLockedFile::Lock()
{
if(Locked) return;
hFile = CreateFile(File.t_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
Locked = true;
}
void TLockedFile::Unlock()
{
if(!Locked) return;
CloseHandle(hFile);
hFile = NULL;
Locked = false;
}
//---------------------------------------------------------------------------
#pragma package(smart_init)