Project

General

Profile

aud.diff

Reimplement vfs_file_test - John Lindgren, November 17, 2012 00:54

View differences:

src/libaudcore/vfs.c
411 411
        return FALSE; /* only local files are handled */
412 412

  
413 413
    char * path2 = uri_to_filename (path);
414
    if (! path2)
415
        return FALSE;
416
    
417
    if (test & VFS_IS_SYMLINK)
418
    {
419
        struct stat st;
420
        if (lstat (path2, & st) < 0)
421
            return FALSE;
422
    
423
        if (S_ISLNK (st.st_mode))
424
            test &= ~VFS_IS_SYMLINK;
425
    }
426
    
427
    if (test & (VFS_IS_REGULAR | VFS_IS_DIR | VFS_IS_EXECUTABLE | VFS_EXISTS))
428
    {
429
        struct stat st;
430
        if (stat (path2, & st) < 0)
431
            return FALSE;
432
        
433
        if (S_ISREG (st.st_mode))
434
            test &= ~VFS_IS_REGULAR;
435
        if (S_ISDIR (st.st_mode))
436
            test &= ~VFS_IS_DIR;
437
        if (st.st_mode & S_IXUSR)
438
            test &= ~VFS_IS_EXECUTABLE;
439
        
440
        test &= ~VFS_EXISTS;
441
    }
414 442

  
415
    if (path2 == NULL)
416
        path2 = g_strdup(path);
417

  
418
    bool_t ret = g_file_test (path2, test);
419

  
420
    g_free(path2);
443
    g_free (path2);
421 444

  
422
    return ret;
445
    return ! test;
423 446
}
424 447

  
425 448
/**