import { IModelStatus } from "@itwin/core-bentley" ; import { IModelError } from "@itwin/core-common" ; import { BriefcaseConnection , IModelConnection , SnapshotConnection } from "@itwin/core-frontend" ; export async function openIModel ( fileName , writable ) { try { return await BriefcaseConnection . openFile ( { fileName , readonly : ! writable , key : fileName } ) ; } catch ( err ) { if ( writable && err instanceof IModelError && err . errorNumber === IModelStatus . ReadOnly ) return SnapshotConnection . openFile ( fileName ) ; else throw err ; } }