/*
**    Name: stat.c
**
**    Date: Sat Jan  1 16:21:19 2005
**
**    Purpose:
**
*/

#include "csfcntl.h"
#include "kernel.h"
#include "osfile.h"
#include <string.h>
#include "sys/types.h"
#include "sys/stat.h"

int stat(const char *file_name,struct stat *buf)
    {
    _kernel_swi_regs regs;

    memset(buf,0,sizeof(struct stat));

    regs.r[0] = OSFile_ReadStampedNoPath;
    regs.r[1] = (int)file_name;

    if (_kernel_swi(XOS_File,&regs,&regs) != NULL) {
        return -1;
    }

    if (regs.r[0] == osfile_NOT_FOUND) {
        return -1;
    }

    buf->st_size = regs.r[4];

    return 0;
    }
