FCNTL_HAS_MOVED.

This commit is contained in:
Nuno Cruces
2023-03-17 14:00:35 +00:00
parent 4cb65ccbd9
commit f38e36109a
2 changed files with 20 additions and 2 deletions

20
vfs.go
View File

@@ -314,7 +314,25 @@ func vfsFileControl(ctx context.Context, mod api.Module, pFile uint32, op _Fcntl
case _FCNTL_SIZE_HINT:
//
case _FCNTL_HAS_MOVED:
//
return vfsFileMoved(ctx, mod, pFile, pArg)
}
return uint32(NOTFOUND)
}
func vfsFileMoved(ctx context.Context, mod api.Module, pFile, pResOut uint32) uint32 {
file := vfsFile.GetOS(ctx, mod, pFile)
fi, err := file.Stat()
if err != nil {
return uint32(IOERR_FSTAT)
}
pi, err := os.Stat(file.Name())
if err != nil && !errors.Is(err, fs.ErrNotExist) {
return uint32(IOERR_FSTAT)
}
var res uint32
if !os.SameFile(fi, pi) {
res = 1
}
memory{mod}.writeUint32(pResOut, res)
return _OK
}

View File

@@ -56,7 +56,7 @@ const (
type vfsLockState uint32
func vfsLock(ctx context.Context, mod api.Module, pFile uint32, eLock vfsLockState) uint32 {
// Argument check. SQLite never explicitly requests a pendig lock.
// Argument check. SQLite never explicitly requests a pending lock.
if eLock != _SHARED_LOCK && eLock != _RESERVED_LOCK && eLock != _EXCLUSIVE_LOCK {
panic(assertErr())
}