Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/viewer/viewer.c

    r10cb47e rc23275a  
    3434
    3535#include <stdio.h>
    36 #include <unistd.h>
    37 #include <fcntl.h>
    38 #include <sys/stat.h>
     36#include <stdlib.h>
     37#include <vfs/vfs.h>
    3938#include <errno.h>
    4039#include <malloc.h>
     
    110109static bool img_load(const char *fname, surface_t **p_local_surface)
    111110{
    112         int fd = open(fname, O_RDONLY);
     111        int fd = vfs_lookup_open(fname, WALK_REGULAR, MODE_READ);
    113112        if (fd < 0)
    114113                return false;
    115114       
    116115        struct stat stat;
    117         int rc = fstat(fd, &stat);
    118         if (rc != 0) {
    119                 close(fd);
     116        int rc = vfs_stat(fd, &stat);
     117        if (rc != EOK) {
     118                vfs_put(fd);
    120119                return false;
    121120        }
     
    123122        void *tga = malloc(stat.size);
    124123        if (tga == NULL) {
    125                 close(fd);
    126                 return false;
    127         }
    128        
    129         ssize_t rd = read(fd, tga, stat.size);
     124                vfs_put(fd);
     125                return false;
     126        }
     127
     128        ssize_t rd = vfs_read(fd, (aoff64_t []) {0}, tga, stat.size);
    130129        if ((rd < 0) || (rd != (ssize_t) stat.size)) {
    131130                free(tga);
    132                 close(fd);
    133                 return false;
    134         }
    135        
    136         close(fd);
     131                vfs_put(fd);
     132                return false;
     133        }
     134       
     135        vfs_put(fd);
    137136       
    138137        *p_local_surface = decode_tga(tga, stat.size, 0);
Note: See TracChangeset for help on using the changeset viewer.