Esempio n. 1
0
char* short_path_to_long_path(char* short_path)
{
    char buffer2[_MAX_PATH];
    int ret = ShortPathToLongPath(short_path, buffer2, _MAX_PATH);

    if (ret)
    return newstr(buffer2);
    else
      return newstr(short_path);
}
Esempio n. 2
0
OBJECT * short_path_to_long_path( OBJECT * short_path )
{
    char buffer2[_MAX_PATH];
    int ret = ShortPathToLongPath( object_str( short_path ), buffer2, _MAX_PATH );

    if (ret)
        return object_new( buffer2 );
    else
        return object_copy( short_path );
}
Esempio n. 3
0
OBJECT * path_as_key( OBJECT * path )
{
    struct path_key_entry * result;
    int found;

    if ( ! path_key_cache )
        path_key_cache = hashinit( sizeof( struct path_key_entry ), "path to key" );

    result = (struct path_key_entry *)hash_insert( path_key_cache, path, &found );
    if ( !found )
    {
        string buf[1];
        OBJECT * normalized;
        struct path_key_entry * nresult;
        result->path = path;
        string_copy( buf, object_str( path ) );
        normalize_path( buf );
        normalized = object_new( buf->value );
        nresult = (struct path_key_entry *)hash_insert( path_key_cache, normalized, &found );
        if ( !found || nresult == result )
        {
            string long_path[1];
            nresult->path = normalized;
            string_new( long_path );
            ShortPathToLongPath( buf->value, long_path );
            nresult->path = object_copy( normalized );
            nresult->key = object_new( long_path->value );
            string_free( long_path );
        }
        string_free( buf );
        object_free( normalized );
        if ( nresult != result )
        {
            result->path = object_copy( path );
            result->key = object_copy( nresult->key );
        }
    }

    return object_copy( result->key );
}
Esempio n. 4
0
static void path_write_key( char * path_, string * out )
{
    struct path_key_entry * result;
    OBJECT * path = object_new( path_ );
    int found;

    /* This is only called by path_as_key, which initializes the cache. */
    assert( path_key_cache );

    result = (struct path_key_entry *)hash_insert( path_key_cache, path, &found );
    if ( !found )
    {
        /* path_ is already normalized. */
        result->path = path;
        ShortPathToLongPath( path_, out );
        result->key = object_new( out->value );
    }
    else
    {
        object_free( path );
        string_append( out, object_str( result->key ) );
    }

}