Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions winapi/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ BOOL ReadFile(
LPOVERLAPPED lpOverlapped
);

BOOL LockFile(
HANDLE hFile,
DWORD dwFileOffsetLow,
DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToLockLow,
DWORD nNumberOfBytesToLockHigh
);

BOOL UnlockFile(
HANDLE hFile,
DWORD dwFileOffsetLow,
DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToUnlockLow,
DWORD nNumberOfBytesToUnlockHigh
);

BOOL FlushFileBuffers(HANDLE hFile);
]]

Expand Down Expand Up @@ -97,6 +113,14 @@ function FlushFileBuffers(hfile)
return retnz(C.FlushFileBuffers(hfile))
end

function LockFile(hfile, offsetLow, offsetHigh, bytesLow, bytesHigh)
return retnz(C.LockFile(hfile, offsetLow, offsetHigh, bytesLow, bytesHigh))
end

function UnlockFile(hfile, offsetLow, offsetHigh, bytesLow, bytesHigh)
return retnz(C.UnlockFile(hfile, offsetLow, offsetHigh, bytesLow, bytesHigh))
end

if not ... then
local tmpname = '_CreateFileTest.tmp'
local f = assert(CreateFile(tmpname, 'GENERIC_WRITE', 0, nil,
Expand Down