Esempio n. 1
0
/* AddSearchPath
 *  add a search path to loader for locating library files
 */
LIB_EXPORT rc_t CC KDyldVAddSearchPath ( KDyld *self, const char *path, va_list args )
{
    rc_t rc;
    if ( self == NULL )
        rc = RC ( rcFS, rcDylib, rcUpdating, rcSelf, rcNull );
    else
    {
        KDirectory *wd;
        rc = KDirectoryNativeDir ( & wd );
        if ( rc == 0 )
        {
            const KDirectory *dir;
            rc = KDirectoryVOpenDirRead ( wd, & dir, false, path, args );
            if ( rc == 0 )
            {
                rc = VectorAppend ( & self -> search, NULL, dir );
                if ( rc != 0 )
                    KDirectoryRelease ( dir );
            }

            KDirectoryRelease ( wd );
        }
    }
    return rc;
}
Esempio n. 2
0
/* GetPathModDate
 *  extract mod date from a path
 */
rc_t KDBVGetPathModDate ( const KDirectory *dir,
    KTime_t *mtime, const char *path, va_list args )
{
    rc_t rc;
    uint32_t ptype;
    const KDirectory *obj_dir;

    va_list cpy;
    va_copy ( cpy, args );
    ptype = KDirectoryVPathType ( dir, path, cpy );
    va_end ( cpy );

    switch ( ptype )
    {
    case kptDir:
    case kptDir | kptAlias:
        break;

    default:
        return KDirectoryVDate ( dir, mtime, path, args );
    }

    * mtime = 0;
    rc = KDirectoryVOpenDirRead ( dir, & obj_dir, true, path, args );
    if ( rc == 0 )
    {
        rc = KDBGetObjModDate ( obj_dir, mtime );
        KDirectoryRelease ( obj_dir );
    }

    return rc;
}
Esempio n. 3
0
 /* OpenDirRead
 * OpenDirUpdate
 *  opens a sub-directory
 *
 *  "chroot" [ IN ] - if true, the new directory becomes
 *  chroot'd and will interpret paths beginning with '/'
 *  relative to itself.
 *
 *  "path" [ IN ] - NUL terminated string in directory-native
 *  character set denoting target directory
 */
 inline rc_t OpenDirRead ( const KDirectory **sub, bool chroot,
    const char *path, ... ) const throw ()
 {
    va_list args;
    va_start ( args, path );
    rc_t rc = KDirectoryVOpenDirRead ( this, sub, chroot, path, args );
    va_end ( args );
    return rc;
 }
Esempio n. 4
0
static
rc_t open_dir_as_archive (const char * path, const KFile ** file)
{
    rc_t rc;
    KPathType kpt;
    const KDirectory * d;

    assert (path != NULL);
    assert (path[0] != '\0');
    assert (file != NULL);

    rc = 0;
    kpt = KDirectoryPathType (kdir, path);
    switch (kpt)
    {
    case kptFile:
        STSMSG (1, ("Opening as archive %s\n", path));

        rc = KDirectoryOpenSraArchiveRead (kdir, &d, false, path);
        if (rc != 0)
            rc = KDirectoryOpenTarArchiveRead (kdir, &d, false, path);
        if (rc != 0)
            rc = RC (rcExe, rcParam, rcOpening, rcDirectory, rcInvalid);
        break;
    default:
        rc = RC (rcExe, rcNoTarg, rcParsing, rcParam, rcInvalid);
        PLOGERR (klogFatal, (klogFatal, rc, "Parameter [$(P)] must be a directory", PLOG_S(P), path));
        return rc;
    case kptDir:
/*         KOutMsg ("%s: opening dir\n",__func__); */
        rc = KDirectoryVOpenDirRead (kdir, &d, false, path, NULL);
    }
    if (rc == 0)
    {
/*         KOutMsg ("%s: dir to archive\n",__func__); */
        rc = KDirectoryOpenTocFileRead (d, file, alignment, pnamesFilter, NULL, sort_size_then_rel_path );
        KDirectoryRelease (d);
    }
    return rc;
}
Esempio n. 5
0
 inline rc_t OpenDirRead ( const KDirectory **sub, bool chroot,
    const char *path, va_list args ) const throw ()
 { return KDirectoryVOpenDirRead ( this, sub, chroot, path, args ); }