/* Make */ static rc_t SRAMgrInitPath ( SRAMgr *mgr, const KDirectory *wd ) { #if OLD_SRAPATH_MGR /* try to make the path manager */ rc_t rc = SRAPathMake ( & mgr -> _pmgr, wd ); if ( GetRCState ( rc ) == rcNotFound && GetRCTarget ( rc ) == rcDylib ) { /* we are operating outside of the archive */ assert ( mgr -> _pmgr == NULL ); rc = 0; } return rc; #else KConfig *kfg; rc_t rc = KConfigMake ( & kfg, NULL ); if ( rc == 0 ) { VFSManager *vfs; rc = VFSManagerMake ( & vfs ); if ( rc == 0 ) { rc = VFSManagerMakeResolver ( vfs, ( VResolver** ) & mgr -> _pmgr, kfg ); VFSManagerRelease ( vfs ); } KConfigRelease ( kfg ); } if ( rc != 0 ) mgr -> _pmgr = NULL; return 0; #endif }
static bool CanResolveAccessions( void ) { bool res = false; SRAPath *sra_path; rc_t rc = SRAPathMake( &sra_path, NULL ); if ( rc == 0 ) { res = true; SRAPathRelease( sra_path ); } return res; }
void CSraPath::x_Init(void) { CSraMgr::RegisterFunctions(); if ( rc_t rc = SRAPathMake(x_InitPtr(), 0) ) { *x_InitPtr() = 0; NCBI_THROW2(CSraException, eInitFailed, "Cannot make SRAPath", rc); } if ( rc_t rc = SRAPathClear(*this) ) { NCBI_THROW2(CSraException, eInitFailed, "Cannot clear SRAPath", rc); } }
static rc_t resolve_accession( const KDirectory *my_dir, char ** path ) { SRAPath *my_sra_path; rc_t rc = 0; if ( strchr ( *path, '/' ) != NULL ) return 0; rc = SRAPathMake( &my_sra_path, my_dir ); if ( rc != 0 ) { if ( GetRCState ( rc ) != rcNotFound || GetRCTarget ( rc ) != rcDylib ) { if ( rc != 0 ) { LOGERR( klogInt, rc, "SRAPathMake() failed" ); } } else rc = 0; } else { if ( !SRAPathTest( my_sra_path, *path ) ) { char *buf = translate_accession( my_sra_path, *path, 64 ); if ( buf != NULL ) { free( (char*)(*path) ); *path = buf; } } SRAPathRelease( my_sra_path ); } return rc; }
rc_t CC KMain ( int argc, char *argv [] ) { Args *args; rc_t rc = ArgsMakeAndHandle ( & args, argc, argv, 0 ); if ( rc != 0 ) LogErr ( klogErr, rc, "failed to parse arguments" ); else { uint32_t paramc; rc = ArgsParamCount ( args, & paramc ); if ( rc != 0 ) LogErr ( klogInt, rc, "failed to obtain param count" ); else { if ( paramc == 0 ) { rc = RC ( rcExe, rcArgv, rcParsing, rcParam, rcInsufficient ); LogErr ( klogErr, rc, "missing target object" ); MiniUsage ( args ); } else if ( paramc > 1 ) { rc = RC ( rcExe, rcArgv, rcParsing, rcParam, rcExcessive ); LogErr ( klogErr, rc, "expected single target object" ); MiniUsage ( args ); } else { const char *target; rc = ArgsParamValue ( args, 0, & target ); if ( rc != 0 ) LogErr ( klogInt, rc, "failed to obtain param value" ); else { VDBManager *mgr; #if TOOLS_USE_SRAPATH != 0 char full [ 4096 ]; SRAPath *sra_path; rc = SRAPathMake ( & sra_path, NULL ); if ( rc == 0 ) { if ( ! SRAPathTest ( sra_path, target ) ) { rc = SRAPathFind ( sra_path, target, full, sizeof full ); if ( rc == 0 ) target = full; } SRAPathRelease ( sra_path ); } #endif rc = VDBManagerMakeUpdate ( & mgr, NULL ); if ( rc != 0 ) LogErr ( klogInt, rc, "failed to open VDB manager" ); else { rc = VDBManagerLock ( mgr, target ); if ( rc == 0 ) pLogMsg ( klogInfo, "locked '$(target)'", "target=%s", target ); else switch ( GetRCState ( rc ) ) { case rcLocked: pLogMsg ( klogInfo, "'$(target)' was already locked", "target=%s", target ); break; default: pLogErr ( klogErr, rc, "failed to lock '$(target)'", "target=%s", target ); } VDBManagerRelease ( mgr ); } } } } ArgsWhack ( args ); } return rc; }
/* Make * create path manager * * the path manager should already be configured with * standard search paths, but can be augmented by using * the Add*Path messages. * * "dir" [ IN, NULL OKAY ] - optional root directory to use * attaches a new reference */ static inline rc_t Make ( SRAPath **pm, struct KDirectory const *dir = NULL ) throw() { return SRAPathMake ( pm, dir ); }