xOpen method
Opens a file, returning supported flags and a file instance.
Implementation
@override
XOpenResult xOpen(Sqlite3Filename path, int flags) {
final pathStr = path.path ?? random.randomFileName(prefix: '/');
final existedBefore = _memory.xAccess(pathStr, 0) != 0;
final inMemoryFile = _memory.xOpen(Sqlite3Filename(pathStr), flags);
final deleteOnClose = (flags & SqlFlag.SQLITE_OPEN_DELETEONCLOSE) != 0;
if (!existedBefore) {
if (deleteOnClose) {
// No point in persisting this file, it doesn't exist and won't exist
// after we're done.
_inMemoryOnlyFiles.add(pathStr);
} else {
_submitWork(_CreateFileWorkItem(this, pathStr));
}
}
return (
outFlags: 0,
file: _IndexedDbFile(this, inMemoryFile.file, pathStr),
);
}