 
/*
 * XKOBO, a video-oriented game
 * Copyright (C) 1995  Akira Higuchi
 *     a-higuti@math.hokudai.ac.jp
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 675 Mass Ave, Cambridge, MA 02139, USA.
 * 
 */

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
 

int load_block(char *file_name, void *t, int len) 
{
    int i, fd;
    
    fd = open(file_name, O_RDONLY, 0);
    if (fd == -1){
        close(fd);
        return -1;
    }
    else {
        i = read(fd, t, len);
        close(fd);
        return i;
    }
}
int save_block(char *file_name, void *t, int len) 
{
    int i, fd;
     
    fd = creat(file_name, 0644);
    if (fd == -1){
        close(fd);
        return -1;
    }
    else {
        i = write(fd, t, len);
        close(fd);
        return (i == len) ? 1 : 0;
    }
}
