void CVPath::x_Init(const CVFSManager& mgr, const string& path, EType type) { VPath* vpath = 0; if ( type == eSys ) { if ( rc_t rc = VFSManagerMakeSysPath(mgr, &vpath, path.c_str()) ) { *x_InitPtr() = 0; NCBI_THROW2_FMT(CSraException, eInitFailed, "Cannot create sys VPath: "<<path, rc); } } else if ( type == eAcc ) { if ( rc_t rc = VFSManagerMakeAccPath(mgr, &vpath, path.c_str()) ) { *x_InitPtr() = 0; NCBI_THROW2_FMT(CSraException, eInitFailed, "Cannot create acc VPath: "<<path, rc); } } else { if ( rc_t rc = VFSManagerMakePath(mgr, &vpath, path.c_str()) ) { *x_InitPtr() = 0; NCBI_THROW2_FMT(CSraException, eInitFailed, "Cannot create VPath: "<<path, rc); } } *x_InitPtr() = vpath; }
static rc_t split_argument_into_path_and_readgroup( const char *argument, char ** path, char ** attribute ) { rc_t rc; char * colon_ptr = string_chr ( argument, string_size ( argument ), ':' ); if ( colon_ptr == NULL ) { /* we do not have a colon in the argument, that means: there is no uri-syntax involved ---> we can split the "old fashioned way" at the equal-sign */ rc = split_argument( argument, path, attribute, '=' ); } else { VFSManager * mgr; rc_t rc = VFSManagerMake ( & mgr ); *path = NULL; *attribute = NULL; if ( rc == 0 ) { VPath * vpath; rc = VFSManagerMakePath ( mgr, &vpath, argument ); if ( rc == 0 ) { rc = test_split_vpath_into_path_and_readgroup( vpath, argument, path, attribute ); VPathRelease( vpath ); } VFSManagerRelease ( mgr ); } } return rc; }
FIXTURE_TEST_CASE(TestManyNoDep, EmptyFixture) { rc_t rc = 0; const char SRR543323[] = "SRR543323"; VPath* acc = NULL; REQUIRE_RC(VFSManagerMakePath(vmgr, &acc, SRR543323)); const VPath *local = NULL; REQUIRE_RC_FAIL(VResolverLocal(resolver, acc, &local)); RELEASE(VPath, acc); struct VSchema *schema; REQUIRE_RC(VDBManagerMakeSRASchema(mgr, &schema)); const VDatabase *db = NULL; REQUIRE_RC(VDBManagerOpenDBRead(mgr, &db, schema, SRR543323)); REQUIRE_RC(VSchemaRelease(schema)); const VDBDependencies *dep = NULL; // missing REQUIRE_RC(VDatabaseListDependencies(db, &dep, true)); uint32_t count = 1; REQUIRE_RC(VDBDependenciesCount(dep, &count)); CHECK_EQUAL(count, (uint32_t)21); RELEASE(VDBDependencies, dep); REQUIRE_RC(VDatabaseListDependencies(db, &dep, false)); REQUIRE_RC(VDBDependenciesCount(dep, &count)); CHECK_EQUAL(count, (uint32_t)21); RELEASE(VDBDependencies, dep); RELEASE(VDatabase, db); RELEASE(VPath, local); }
FIXTURE_TEST_CASE(Test1LocalDep, EmptyFixture) { rc_t rc = 0; const char SRR413283[] = "SRR413283"; VPath* acc = NULL; REQUIRE_RC(VFSManagerMakePath(vmgr, &acc, SRR413283)); const VPath *local = NULL; REQUIRE_RC_FAIL(VResolverLocal(resolver, acc, &local)); RELEASE(VPath, acc); const VDatabase *db = NULL; REQUIRE_RC(VDBManagerOpenDBRead(mgr, &db, NULL, SRR413283)); const VDBDependencies *dep = NULL; // missing REQUIRE_RC(VDatabaseListDependencies(db, &dep, true)); uint32_t count = 1; REQUIRE_RC(VDBDependenciesCount(dep, &count)); CHECK_EQUAL(count, (uint32_t)0); RELEASE(VDBDependencies, dep); REQUIRE_RC(VDatabaseListDependencies(db, &dep, false)); REQUIRE_RC(VDBDependenciesCount(dep, &count)); CHECK_EQUAL(count, (uint32_t)1); RELEASE(VDBDependencies, dep); RELEASE(VDatabase, db); RELEASE(VPath, local); }
static rc_t transform_to_utf8_and_make_vpath ( const VFSManager * self, VPath ** new_path, const wchar_t * src, bool dos_path ) { rc_t rc = 0; size_t src_size, dst_size; uint32_t len = wchar_cvt_string_measure ( src, & src_size, & dst_size ); if ( len == 0 ) rc = RC ( rcVFS, rcMgr, rcConstructing, rcPath, rcEmpty ); else { /* transform to UTF-8 */ size_t copy_size; char utf8_path [ 4096 ], *dst = utf8_path; if ( dst_size < sizeof utf8_path ) dst_size = sizeof utf8_path; else { dst = malloc ( ++ dst_size ); if ( dst == NULL ) return RC ( rcVFS, rcMgr, rcConstructing, rcMemory, rcExhausted ); } copy_size = wchar_cvt_string_copy ( dst, dst_size, src, src_size ); if ( copy_size >= dst_size ) rc = RC ( rcVFS, rcMgr, rcConstructing, rcBuffer, rcInsufficient ); else { size_t i = 0; dst [ copy_size ] = 0; /* encode drive letter */ if ( dos_path ) { assert ( isalpha ( dst [ 0 ] ) ); assert ( dst [ 1 ] == ':' ); dst [ 1 ] = dst [ 0 ]; dst [ 0 ] = '/'; i = 2; } /* convert '\\' to '/' */ for ( ; i < copy_size; ++ i ) { if ( dst [ i ] == '\\' ) dst [ i ] = '/'; } /* this is the final goal! */ rc = VFSManagerMakePath ( self, new_path, "%.*s", ( uint32_t ) copy_size, dst ); } if ( dst != utf8_path ) free ( dst ); } return rc; }
static rc_t CC XFS_ReadCEverything_ZHR ( const char * Url, char * Buffer, size_t BufferSize, const char * Filler, XFS_ReadV_ZHR Reader ) { rc_t RCt; size_t NR; const char * DefaultFiller = "NULL"; struct VPath * Path; RCt = 0; NR = 0; Path = NULL; if ( Buffer == NULL || BufferSize <= 0 ) { return XFS_RC ( rcNull ); } * Buffer = 0; if ( Url == NULL ) { RCt = XFS_RC ( rcNull ); string_copy_measure ( Buffer, sizeof ( Buffer ), ( Filler == NULL ? DefaultFiller : Filler ) ); } else { RCt = VFSManagerMakePath ( XFS_VfsManager (), & Path, Url ); if ( RCt == 0 ) { RCt = Reader ( Path, Buffer, BufferSize, & NR ); VPathRelease ( Path ); } } return RCt; } /* XFS_ReadCEverything_ZHR () */
static rc_t resolve_accession( VFSManager * vfs_mgr, const char * acc, const String ** resolved ) { VResolver * resolver; rc_t rc = VFSManagerGetResolver( vfs_mgr, &resolver ); if ( rc != 0 ) { (void)LOGERR( klogErr, rc, "VFSManagerGetResolver() failed" ); } else { VPath * acc_vpath; rc = VFSManagerMakePath( vfs_mgr, &acc_vpath, "ncbi-acc:%s", acc ); if ( rc != 0 ) { (void)LOGERR( klogErr, rc, "VFSManagerMakePath() failed" ); } else { const VPath * local = NULL; const VPath * remote = NULL; rc = VResolverQuery ( resolver, 0, acc_vpath, &local, &remote, NULL ); if ( rc != 0 ) { (void)LOGERR( klogErr, rc, "VResolverQuery() failed" ); } else { if ( local != NULL ) rc = VPathMakeString( local, resolved ); else if ( remote != NULL ) rc = VPathMakeString( remote, resolved ); else rc = KOutMsg( "cannot resolve '%s'\n", acc ); if ( local != NULL ) VPathRelease ( local ); if ( remote != NULL ) VPathRelease ( remote ); } VPathRelease ( acc_vpath ); } VResolverRelease( resolver ); } return rc; }
FIXTURE_TEST_CASE(Test1YesDep, RefseqFixture) { if (siteless) { TEST_MESSAGE("Test skipped because site repository does not exist"); return; } rc_t rc = 0; const VDatabase *db = NULL; const char SRR619505[] = "SRR619505"; REQUIRE_RC(VDBManagerOpenDBRead(mgr, &db, NULL, SRR619505)); RELEASE(VDatabase, db); VPath* acc = NULL; REQUIRE_RC(VFSManagerMakePath(vmgr, &acc, SRR619505)); const VPath *local = NULL; REQUIRE_RC(VResolverLocal(resolver, acc, &local)); RELEASE(VPath, acc); const String *s = NULL; REQUIRE_RC(VPathMakeString(local, &s)); REQUIRE(s && s->addr); REQUIRE_RC(VDBManagerOpenDBRead(mgr, &db, NULL, s->addr)); const VDBDependencies *dep = NULL; // missing REQUIRE_RC(VDatabaseListDependencies(db, &dep, true)); uint32_t count = 1; REQUIRE_RC(VDBDependenciesCount(dep, &count)); CHECK_EQUAL(count, (uint32_t)0); RELEASE(VDBDependencies, dep); REQUIRE_RC(VDatabaseListDependencies(db, &dep, false)); REQUIRE_RC(VDBDependenciesCount(dep, &count)); CHECK_EQUAL(count, (uint32_t)1); RELEASE(VDBDependencies, dep); RELEASE(VDatabase, db); free(const_cast<String*>(s)); RELEASE(VPath, local); }
/* ---------------------------------------------------------------------- */ static rc_t open_xml_then_run() { rc_t rc; rc = VFSManagerMakePath (options.vfsmgr, &options.xmlpath, "%s", options.xmlstr); if (rc) PLOGERR (klogInt, (klogInt, rc, "failed to create path for '$(P)'", "P=%s", options.xmlstr)); else { rc = VFSManagerOpenFileRead (options.vfsmgr, &options.xml, options.xmlpath); if (rc) LOGERR (klogErr, rc, "Failed to open output directoryCopycat XML file"); else { rc = open_root_then_run (); } VPathRelease (options.xmlpath); } return rc; }
/* ---------------------------------------------------------------------- */ static rc_t open_dir_then_run() { rc_t rc; rc = VFSManagerMakePath (options.vfsmgr, &options.dirpath, "%s", options.dirstr); if (rc) PLOGERR (klogInt, (klogInt, rc, "failed to create path for '$(P)'", "P=%s", options.dirstr)); else { rc = VFSManagerOpenDirectoryUpdate (options.vfsmgr, &options.dir, options.dirpath); if (rc) LOGERR (klogErr, rc, "Failed to open output directory"); else { rc = open_xml_then_run(); KDirectoryRelease (options.dir); } VPathRelease (options.dirpath); } return rc; }
LIB_EXPORT rc_t CC XFS_HttpStreamMake_ZHR ( const char * Url, const struct XFSHttpStream ** Stream ) { rc_t RCt; struct VPath * Path; struct String Host; uint32_t Port; struct XFSHttpStream * TheStream; RCt = 0; Path = NULL; if ( Stream != NULL ) { * Stream = NULL; } if ( Url == NULL || Stream == NULL ) { return XFS_RC ( rcNull ); } RCt = VFSManagerMakePath ( XFS_VfsManager (), & Path, Url ); if ( RCt == 0 ) { RCt = VPathGetHost ( Path, & Host ); if ( RCt == 0 ) { Port = VPathGetPortNum ( Path ); TheStream = calloc ( 1, sizeof ( struct XFSHttpStream ) ); if ( TheStream == NULL ) { RCt = XFS_RC ( rcExhausted ); } else { RCt = KNSManagerMakeHttp ( XFS_KnsManager(), & ( TheStream -> http ), NULL, 0x01010000, & Host, Port ); if ( RCt == 0 ) { RCt = KHttpMakeRequest ( TheStream -> http, & ( TheStream -> req ), Url ); if ( RCt == 0 ) { RCt = KHttpRequestGET ( TheStream -> req, & ( TheStream -> res ) ); if ( RCt == 0 ) { RCt = KHttpResultGetInputStream ( TheStream -> res, & ( TheStream -> str ) ); if ( RCt == 0 ) { TheStream -> completed = false; TheStream -> last_error = 0; * Stream = TheStream; } } } } } } VPathRelease ( Path ); } if ( RCt != 0 ) { * Stream = NULL; if ( TheStream != NULL ) { XFS_HttpStreamDispose_ZHR ( TheStream ); } } return RCt; } /* XFS_HttpStreamMake_ZHR () */
static rc_t nenctool (const char * srcstr, const char * dststr, bool force) { VFSManager * mgr; rc_t rc; rc = VFSManagerMake (&mgr); if (rc) LOGERR (klogInt, rc, "failed to create file system manager"); else { VPath * srcpath; rc = VFSManagerMakePath (mgr, &srcpath, "%s", srcstr); if (rc) PLOGERR (klogErr, (klogErr, rc, "Failed to parse source path '$(path)'", "path=%s", srcstr)); else { VPath * dstpath; rc = VFSManagerMakePath (mgr, &dstpath, "%s", dststr); if (rc) PLOGERR (klogErr, (klogErr, rc, "Failed to parse destination path '$(path)'", "path=%s", dststr)); else { const KFile * srcfile; rc = VFSManagerOpenFileRead (mgr, &srcfile, srcpath); if (rc) PLOGERR (klogErr, (klogErr, rc, "Failed to open source path '$(path)'", "path=%s", srcstr)); else { KFile * dstfile; rc = VFSManagerCreateFile (mgr, &dstfile, false, 0666, kcmParents | (force ? kcmInit : kcmCreate), dstpath); if (rc) PLOGERR (klogErr, (klogErr, rc, "failed to open destination path '$(path)'", "path=%s", dststr)); else { rc = copy_file (srcstr, dststr, srcfile, dstfile); if (rc) { PLOGERR (klogErr, (klogErr, rc, "failed to copy '$(S)' to '$(D)'", "S=%s,D=%s", srcstr, dststr)); VFSManagerRemove (mgr, true, dstpath); } KFileRelease (dstfile); } KFileRelease (srcfile); } VPathRelease (dstpath); } VPathRelease (srcpath); } VFSManagerRelease (mgr); } return rc; }
static rc_t tokenize_file_and_progname_into_argv( const char * filename, const char * progname, int * argc, char *** argv ) { rc_t rc2, rc = 0; VFSManager *vfs_mgr; ( *argv ) = NULL; ( *argc ) = 0; rc = VFSManagerMake ( &vfs_mgr ); if ( rc != 0 ) LOGERR( klogInt, rc, "VFSManagerMake() failed" ); else { VPath * vfs_path; rc = VFSManagerMakePath ( vfs_mgr, &vfs_path, "%s", filename ); if ( rc != 0 ) LOGERR( klogInt, rc, "VPathMake() failed" ); else { struct KFile const *my_file; rc = VFSManagerOpenFileRead ( vfs_mgr, &my_file, vfs_path ); if ( rc != 0 ) LOGERR( klogInt, rc, "VFSManagerOpenFileRead() failed" ); else { tokenzr *t; uint64_t pos = 0; char buffer[ 4096 + 1 ]; size_t num_read; rc = make_tokenzr( &t, argc, argv ); if ( rc != 0 ) LOGERR( klogInt, rc, "make_tokenzr() failed" ); else { if ( progname != NULL ) rc = add_string_to_argv( t, progname, string_size( progname ) ); if ( rc == 0 ) { do { rc = KFileRead ( my_file, pos, buffer, ( sizeof buffer ) - 1, &num_read ); if ( rc != 0 ) LOGERR( klogInt, rc, "KFileRead() failed" ); else if ( num_read > 0 ) { buffer[ num_read ] = 0; rc = tokenize_buffer( t, buffer, num_read ); if ( rc != 0 ) LOGERR( klogInt, rc, "tokenize_buffer() failed" ); pos += num_read; } } while ( rc == 0 && num_read > 0 ); } if ( rc == 0 && t->used > 0 ) { rc = add_token_to_argv( t ); if ( rc != 0 ) LOGERR( klogInt, rc, "add_token_to_argv() failed" ); } free_tokenzr( t ); } rc2 = KFileRelease ( my_file ); if ( rc2 != 0 ) LOGERR( klogInt, rc2, "KFileRelease() failed" ); } rc2 = VPathRelease ( vfs_path ); if ( rc2 != 0 ) LOGERR( klogInt, rc2, "VPathRelease() failed" ); } rc2 = VFSManagerRelease ( vfs_mgr ); if ( rc2 != 0 ) LOGERR( klogInt, rc2, "VFSManagerRelease() failed" ); } return rc; }
/* return configured password as ASCIZ * opertates on vfs/kfs/kfg objects, not kdb objects */ static rc_t KDBOpenFileGetPassword (char * pw, size_t pwz) { VFSManager * mgr; rc_t rc; assert (pw); assert (pwz); pw[0] = '\0'; rc = VFSManagerMake (&mgr); if (rc) ; /* failure to make VFS manager: pass along rc */ else { size_t pwfz; char pwf [4096 + 1]; rc = VFSManagerGetConfigPWFile (mgr, pwf, sizeof (pwf) - 1, &pwfz); if (rc) /* failure to get password file path: tweak rc */ rc = RC (rcDB, rcMgr, rcOpening, rcEncryptionKey, rcNotFound); else { VPath * pwp; pwf [pwfz] = '\0'; /* force to ASCIZ */ #if 0 rc = VPathMakeSysPath (&pwp, pwf); #else rc = VFSManagerMakePath (mgr, &pwp, pwf); #endif if (rc) ; /* failure to construct a path from the string */ else { const KFile * pwf; rc = VFSManagerOpenFileRead (mgr, &pwf, pwp); if (rc) /* failure to open password file */ rc = RC (rcDB, rcMgr, rcOpening, rcEncryptionKey, rcNotOpen); else { size_t z; char pwb [4098]; /* arbitrarily using 4096 as maximum allowed length */ /* at this point we are only getting the password from a * file but in the future if we can get it from a pipe of * some sort we can't count on the ReadAll to really know * if we hit end of file and not just a pause in the * streaming. VFS/KFS 2 will have to fix this somehow */ rc = KFileReadAll (pwf, 0, pwb, sizeof pwb, &z); if (rc) ; /* failure to read password file: pass along rc */ else { /* trim off EOL if present */ char * pc; pwb[z] = '\0'; /* force ASCIZ */ pc = string_chr (pwb, z, '\r'); if (pc) { *pc = '\0'; z = 1 + pc - pwb; } pc = string_chr (pwb, z, '\n'); if (pc) { *pc = '\0'; z = 1 + pc - pwb; } if (z == 0) rc = RC (rcDB, rcMgr, rcOpening, rcEncryptionKey, rcTooShort); else if (pwz < z) /* pwz came in as 4096 */ rc = RC (rcDB, rcMgr, rcOpening, rcEncryptionKey, rcTooLong); else { memmove (pw, pwb, z+1); } } KFileRelease (pwf); } VPathRelease (pwp); } } VFSManagerRelease (mgr); } return rc; }
/* ---------------------------------------------------------------------- */ static void CC build_vpath_one (void * item, void * data) { const char * path; rc_data * prc; path = item; prc = data; if (prc->rc == 0) { static const char ccid [] = "copycat-id:"; const size_t cz = sizeof (ccid) - 1; size_t pz; const char * hier; const char * ppath; VPath * vpath; rc_t rc; char vbuff [8193]; rc = 0; ppath = path; pz = string_size (path); hier = string_chr (path, pz, ':'); if ((hier != NULL) && (0 == string_cmp (path, (hier+1) - path, ccid, cz /*sizeof (ccid) - 1*/, cz))) { static const char nfile[] = "ncbi-file:"; char * qmark; size_t s, r/*, q */; char ibuff [8192]; char rbuff [8192]; ++hier; s = hier - path; r = string_copy (ibuff, sizeof (ibuff), hier, pz - s); qmark = string_chr (ibuff, r, '?'); if (qmark == NULL) /* this is more future with parts */ qmark = string_chr (ibuff, r, '#'); if (qmark != NULL) *qmark = '\0'; rc = KDirectoryResolveAlias (options.root, true, rbuff, sizeof (rbuff), "%s", ibuff); if (rc) PLOGERR (klogErr, (klogErr, rc, "error resolving file id '$(I)", "I=%s", ibuff)); else { char * slash; size_t z; slash = string_chr (rbuff+1, sizeof (rbuff), '/'); if (slash == NULL) /* we won't extract the root */ return; ++slash; z = string_size (slash); if (z == 0) return; if (qmark) { s = string_copy (vbuff, sizeof (vbuff), nfile, sizeof (nfile)); r = string_copy (vbuff + s, sizeof (vbuff) - s, slash, z); /*q = */string_copy (vbuff + s + r, (sizeof (vbuff) - s) - r, qmark, pz - (qmark - path)); } else { s = string_copy (vbuff, sizeof (vbuff), slash, z); } ppath = vbuff; } } if (rc == 0) { rc = VFSManagerMakePath (options.vfsmgr, &vpath, "%s", ppath); if (rc) ; else { rc = VectorAppend (&options.pathvpath, NULL, vpath); if (rc) { VPathRelease (vpath); } } } prc->rc = rc; } }
/* KMain */ rc_t CC KMain ( int argc, char *argv [] ) { Args * args; rc_t rc; rc = ArgsMakeAndHandle (&args, argc, argv, 0); if (rc) LOGERR (klogInt, rc, "failed to parse arguments"); else do { uint32_t acount; rc = ArgsParamCount (args, &acount); if (rc) { LOGERR (klogInt, rc, "failed to count parameters"); break; } if (acount == 0) { rc = MiniUsage (args); break; } else { VFSManager* mgr; rc = VFSManagerMake(&mgr); if (rc) LOGERR ( klogErr, rc, "failed to create VFSManager object" ); else { VResolver * resolver; rc = VFSManagerGetResolver (mgr, &resolver); if (rc == 0) { uint32_t ix; for ( ix = 0; ix < acount; ++ ix ) { const char * pc; rc = ArgsParamValue (args, ix, &pc ); if (rc) LOGERR (klogInt, rc, "failed to retrieve parameter value"); else { const VPath * upath = NULL; rc = VFSManagerMakePath ( mgr, (VPath**)&upath, "%s", pc); if (rc == 0) { const VPath * local; const VPath * remote; rc = VResolverQuery (resolver, eProtocolHttp, upath, &local, &remote, NULL); if (rc == 0) { const String * s; if (local != NULL) rc = VPathMakeString (local, &s); else rc = VPathMakeString (remote, &s); if (rc == 0) { OUTMSG (("%S\n", s)); free ((void*)s); } VPathRelease (local); VPathRelease (remote); } else { KDirectory * cwd; rc_t orc = VFSManagerGetCWD (mgr, &cwd); if (orc == 0) { KPathType kpt = KDirectoryPathType(cwd, "%s", pc); switch (kpt &= ~kptAlias) { case kptNotFound: STSMSG(1, ("'%s': not found while " "searching the file system", pc)); break; case kptBadPath: STSMSG(1, ("'%s': bad path while " "searching the file system", pc)); break; default: STSMSG(1, ("'%s': " "found in the file system", pc)); rc = 0; break; } } if (orc == 0 && rc == 0) { if (rc != 0) { PLOGMSG(klogErr, (klogErr, "'$(name)': not found", "name=%s", pc)); } else { char resolved[PATH_MAX] = ""; rc = KDirectoryResolvePath(cwd, true, resolved, sizeof resolved, "%s", pc); if (rc == 0) { STSMSG(1, ("'%s': found in " "the current directory at '%s'", pc, resolved)); OUTMSG (("%s\n", resolved)); } else { STSMSG(1, ("'%s': cannot resolve " "in the current directory", pc)); OUTMSG (("./%s\n", pc)); } } } KDirectoryRelease(cwd); } } RELEASE(VPath, upath); } } VResolverRelease (resolver); } VFSManagerRelease(mgr); } } ArgsWhack (args); } while (0); return rc; }
/* ---------------------------------------------------------------------- * SCHEME:PATH/FILE?QUERY * * form_one is just a file * form_two is just a path and a file (can ignore scheme until more schemes supported) * form_three is all parts except path present which for here acts like form_one * form_four is all four parts * * path is the directory path leading to root * root will be the directory containing the archive * base will be the archive as a directory */ static rc_t open_root_then_run () { static const char dot[] = "."; char rootstr [8192]; char basestr [8192]; const char * colon; rc_t rc; colon = strchr (options.arcstr, ':'); if (colon == NULL) /* no scheme so it has to be a plain path */ { char * last_slash; strcpy (basestr, options.arcstr); last_slash = strrchr (basestr, '/'); if (last_slash == NULL) /* in this directory */ { options.rootstr = dot; options.basestr = options.arcstr; /* done */ } else { *last_slash = '\0'; options.rootstr = basestr; options.basestr = last_slash + 1; /* done */ } } else { char * end_of_root; char * last_slash; strcpy (rootstr, colon+1); end_of_root = strchr (rootstr, '?'); if (end_of_root == NULL) end_of_root = strchr (rootstr, '#'); if (end_of_root) *end_of_root = '\0'; options.rootstr = rootstr; last_slash = strchr (rootstr, '/'); if (last_slash == NULL) { /* no path */ options.rootstr = dot; options.basestr = options.arcstr; /* done */ } else { size_t x,z; *last_slash = '\0'; options.rootstr = rootstr; /* scheme */ z = string_size (rootstr); x = string_copy (basestr, sizeof (basestr), options.arcstr, (colon + 1) - options.arcstr); strcpy (basestr + x, options.arcstr + x + z + 1); options.basestr = basestr; /* done */ } } { KDirectory * cwd; rc = VFSManagerGetCWD (options.vfsmgr, &cwd); if (rc) ; else { rc = KDirectoryOpenXTocDirRead (cwd, &options.root, true, options.xml, "%s", options.rootstr); if (rc) PLOGERR (klogErr, (klogErr, rc, "failed to open XFS from '$(P)' using '$(P)'", "P=%s", options.basestr, options.xmlstr)); else { rc = VFSManagerMakePath (options.vfsmgr, &options.basepath, "%s", options.basestr); if (rc) PLOGERR (klogErr, (klogErr, rc, "failed to make vpath from '$(P)'", "P=%s", options.basestr)); else { rc = VFSManagerOpenDirectoryRead (options.vfsmgr, &options.base, options.basepath); if (rc == 0) { rc = build_vpath_then_run (); KDirectoryRelease (options.base); } KDirectoryRelease (options.root); } VPathRelease (options.basepath); } KDirectoryRelease (cwd); } } return rc; }