xOpen method

  1. @override
XOpenResult xOpen(
  1. Sqlite3Filename path,
  2. int flags
)
override

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: '/');
  if (!fileData.containsKey(pathStr)) {
    final create = flags & SqlFlag.SQLITE_OPEN_CREATE;

    if (create != 0) {
      fileData[pathStr] = Uint8Buffer();
    } else {
      throw VfsException(SqlError.SQLITE_CANTOPEN);
    }
  }

  return (
    outFlags: 0,
    file: _InMemoryFile(
      this,
      pathStr,
      flags & SqlFlag.SQLITE_OPEN_DELETEONCLOSE != 0,
    ),
  );
}