Esempio n. 1
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. 2
0
 /* PathType
  *  returns a KPathType
  *
  *  "path" [ IN ] - NUL terminated string in directory-native character set
  */
 inline uint32_t PathType ( const char *path, ... ) const throw ()
 {
     va_list args;
     va_start ( args, path );
     uint32_t r = KDirectoryVPathType ( this, path, args );
     va_end ( args );
     return r;
 }
Esempio n. 3
0
int KDBPathType ( const KDirectory *dir, bool *pHasZombies, const char *path )
{
    const char *leaf, *parent;


    rc_t rc;
    int type = KDirectoryVPathType ( dir, path, NULL );
    
    if (pHasZombies)
        *pHasZombies = false;

    switch ( type )
    {
    case kptDir:
    case kptDir | kptAlias:
        type = KDBPathTypeDir (dir, type, pHasZombies, path);
        break;

    case kptFile:
    case kptFile | kptAlias:
    {
        /* if we hit a file first try it as an archive */
        const KDirectory * ldir;

        rc = KDirectoryOpenSraArchiveRead_silent ( dir, &ldir, false, path );
        if ( rc != 0 )
            rc = KDirectoryOpenTarArchiveRead_silent ( dir, &ldir, false, path );
        /* it was an archive so recur */
        if ( rc == 0 )
        {
            /* recheck this newly opened directory for KDB/KFS type */
            int type2;

            type2 = KDBPathType ( ldir, NULL, "." );
            if ((type2 != kptDir) || (type != (kptDir|kptAlias)))
                type = type2;

            KDirectoryRelease (ldir);
        }
        /* it was not an archive so see if it it's an idx file */
        else
        {
            leaf = strrchr ( path, '/' );
            if ( leaf != NULL )
            {
                parent = string_rchr ( path, leaf - path, '/' );
                if ( parent ++ == NULL )
                    parent = path;
                if ( memcmp ( parent, "idx/", 4 ) == 0 )
                    type += kptIndex - kptFile;
            }
        }
        break;
    }
    }
    return type;
}
Esempio n. 4
0
/** Check file existance */
static bool SpotIteratorFileExists(const char* path, ...)
{
    bool found = false;
    if (SpotIteratorInitDirectory() == 0)
    {
        uint32_t type
        va_list args;
        va_start(args, path);

        type = KDirectoryVPathType(__SpotIteratorDirectory, path, args);
        found = (type != kptNotFound);
        va_end(args);
    }
    return found;
}
Esempio n. 5
0
static
bool PathExists (const KDirectory * dir, KPathType desired_type, const char * path, ...)
{
    KPathType found_type;
    bool found;
    va_list args;

    va_start (args, path);

    found_type = KDirectoryVPathType (dir, path, args);
    found_type &= ~kptAlias;

    found = (found_type == desired_type)

    va_end (args);
    return found;
}
Esempio n. 6
0
rc_t CCCopyDo (CCCopy * self)
{
    rc_t rc = 0;
    enum KPathType type;

    assert (self != NULL);
    assert (self->path != NULL);

    type = KDirectoryVPathType (self->in, self->path, NULL);
    switch (type & ~kptAlias)
    {
    case kptNotFound:
	rc = RC (rcExe, rcPath, rcAccessing, rcPath, rcNotFound);
	break;
    default:
    case kptBadPath:
	rc = RC (rcExe, rcPath, rcAccessing, rcPath, rcInvalid);
	break;
    case kptFile:
	rc = CCCopyDoFile (self);
	break;
    case kptDir:
#if 0
	rc = CCCopyDoDirectory (self);
#else
	rc = PLOGMSG (klogInfo, "Ignoring directory $(p)",PLOG_S(p),self->path);
#endif
	break;
    case kptCharDev:
	rc = PLOGMSG (klogInfo, "Ignoring kptCharDev $(p)",PLOG_S(p),self->path);
	break;
    case kptBlockDev:
	rc = PLOGMSG (klogInfo, "Ignoring kptBlockDev $(p)",PLOG_S(p),self->path);
	break;
    case kptFIFO:
	rc = PLOGMSG (klogInfo, "Ignoring kptFIFO $(p)",PLOG_S(p),self->path);
	break;
    }
    return rc;
}
Esempio n. 7
0
 inline uint32_t PathType ( const char *path, va_list args ) const throw ()
 { return KDirectoryVPathType ( this, path, args ); }