static rc_t report_deletes_spec( const VDBManager *vdb_mgr, VFSManager * vfs_mgr, const char * spec, uint32_t min_len ) { rc_t rc = KOutMsg( "\nreporting deletes of '%s'\n", spec ); if ( rc == 0 ) { VPath * path = NULL; const VPath * local_cache = NULL; const KFile * remote_file = NULL; rc = VFSManagerResolveSpec ( vfs_mgr, spec, &path, &remote_file, &local_cache, true ); if ( rc != 0 ) { (void)LOGERR( klogErr, rc, "cannot resolve spec via VFSManager" ); } else { char buffer[ 4096 ]; size_t num_read; rc = VPathReadPath ( path, buffer, sizeof buffer, &num_read ); if ( rc != 0 ) { (void)LOGERR( klogErr, rc, "cannot read path from vpath" ); } else { int path_type = ( VDBManagerPathType ( vdb_mgr, "%s", buffer ) & ~ kptAlias ); switch( path_type ) { case kptDatabase : rc = report_deletes_db( vdb_mgr, buffer, min_len ); break; case kptTable : KOutMsg( "cannot report deletes on a table-object\n" ); rc = RC ( rcApp, rcNoTarg, rcAccessing, rcParam, rcInvalid ); (void)LOGERR( klogErr, rc, "cannot report references on a table-object" ); break; default : KOutMsg( "the given object is not a vdb-database\n" ); rc = RC ( rcApp, rcNoTarg, rcAccessing, rcParam, rcInvalid ); (void)LOGERR( klogErr, rc, "the given object is not a vdb-database" ); break; } } KFileRelease( remote_file ); VPathRelease ( local_cache ); VPathRelease ( path ); } } return rc; }
static rc_t report_references( const VDBManager *vdb_mgr, VFSManager * vfs_mgr, const char * spec, bool extended ) { rc_t rc = KOutMsg( "\nreporting references of '%s'\n", spec ); if ( rc == 0 ) { VPath * path = NULL; const VPath * local_cache = NULL; const KFile * remote_file = NULL; rc = VFSManagerResolveSpec ( vfs_mgr, spec, &path, &remote_file, &local_cache, true ); if ( rc != 0 ) { (void)LOGERR( klogErr, rc, "cannot resolve spec via VFSManager" ); } else { char buffer[ 4096 ]; size_t num_read; rc = VPathReadPath ( path, buffer, sizeof buffer, &num_read ); if ( rc != 0 ) { (void)LOGERR( klogErr, rc, "cannot read path from vpath" ); } else { rc = KOutMsg( "resolved into '%s'\n", buffer ); if ( rc == 0 ) { int path_type = ( VDBManagerPathType ( vdb_mgr, "%s", buffer ) & ~ kptAlias ); switch( path_type ) { case kptDatabase : rc = report_ref_database( vdb_mgr, vfs_mgr, buffer, extended ); break; case kptTable : rc = KOutMsg( "cannot report references on a table-object\n" ); break; default : rc = KOutMsg( "the given object is not a vdb-database\n" ); break; } } } KFileRelease( remote_file ); VPathRelease ( local_cache ); VPathRelease ( path ); } } return rc; }
static rc_t ref_walker_prepare_1_src( struct ref_walker * self, const char * name ) { VPath * path = NULL; const VPath * local_cache = NULL; const KFile * remote_file = NULL; rc_t rc = VFSManagerResolveSpec ( self->vfs_mgr, name, &path, &remote_file, &local_cache, true ); if ( rc != 0 ) { PLOGERR( klogErr, ( klogErr, rc, "cannot resolve '$(n)' via VFSManager", "n=%s", name ) ); } else { char buffer[ 4096 ]; size_t num_read; rc = VPathReadPath ( path, buffer, sizeof buffer, &num_read ); if ( rc != 0 ) { PLOGERR( klogErr, ( klogErr, rc, "cannot read path from vpath for '$(n)'", "n=%s", name ) ); } else { if ( rc == 0 ) { int path_type = ( VDBManagerPathType ( self->vmgr, "%s", buffer ) & ~ kptAlias ); if ( path_type == kptDatabase ) { const ReferenceList * reflist; uint32_t options = ( ereferencelist_usePrimaryIds | ereferencelist_useSecondaryIds | ereferencelist_useEvidenceIds ); rc = ReferenceList_MakePath( &reflist, self->vmgr, name, options, 0, NULL, 0 ); if ( rc != 0 ) { PLOGERR( klogErr, ( klogErr, rc, "cannot create ReferenceList for '$(n)'", "n=%s", name ) ); } else { uint32_t count; rc = ReferenceList_Count( reflist, &count ); if ( rc != 0 ) { PLOGERR( klogErr, ( klogErr, rc, "ReferenceList_Count() for '$(n)' failed", "n=%s", name ) ); } else { uint32_t idx; for ( idx = 0; idx < count && rc == 0; ++idx ) { const ReferenceObj * refobj; rc = ReferenceList_Get( reflist, &refobj, idx ); if ( rc != 0 ) { LOGERR( klogInt, rc, "ReferenceList_Get() failed" ); } else { const char * seqid; rc = ReferenceObj_SeqId( refobj, &seqid ); if ( rc == 0 ) { INSDC_coord_len seqlen; rc = ReferenceObj_SeqLength( refobj, &seqlen ); if ( rc == 0 ) { rc = add_region( &self->regions, seqid, 0, seqlen - 1 ); } } ReferenceObj_Release( refobj ); } } } ReferenceList_Release( reflist ); } } } } KFileRelease( remote_file ); VPathRelease ( local_cache ); VPathRelease ( path ); } return rc; }