mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
FCNTL_HAS_MOVED.
This commit is contained in:
20
vfs.go
20
vfs.go
@@ -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
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user