Skip to content

Lock/Unlock functions #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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