OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [rdos/] [open.c] - Diff between revs 148 and 158

Only display areas with differences | Details | Blame | View Log

Rev 148 Rev 158
/*#######################################################################
/*#######################################################################
# RDOS operating system
# RDOS operating system
# Copyright (C) 1988-2006, Leif Ekblad
# Copyright (C) 1988-2006, Leif Ekblad
#
#
# This library is free software; you can redistribute it and/or modify
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This library is distributed in the hope that it will be useful,
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
# GNU Lesser General Public License for more details.
#
#
# You should have received a copy of the GNU Lesser General Public
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# The author of this program may be contacted at leif@rdos.net
# The author of this program may be contacted at leif@rdos.net
#
#
# open.c
# open.c
# open function implementation
# open function implementation
#
#
##########################################################################*/
##########################################################################*/
 
 
#include "config.h"
#include "config.h"
#include <_ansi.h>
#include <_ansi.h>
#include <_syslist.h>
#include <_syslist.h>
#include <fcntl.h>
#include <fcntl.h>
#include <errno.h>
#include <errno.h>
#include "rdos.h"
#include "rdos.h"
#include <stdarg.h>
#include <stdarg.h>
 
 
int open(const char *file, int flags, ...)
int open(const char *file, int flags, ...)
{
{
        int handle;
        int handle;
        int pos;
        int pos;
 
 
        if (flags & O_CREAT)
        if (flags & O_CREAT)
                handle = RdosCreateFile(file, flags);
                handle = RdosCreateFile(file, flags);
        else
        else
                handle = RdosOpenFile(file, flags);
                handle = RdosOpenFile(file, flags);
 
 
        if (handle >= 0)
        if (handle >= 0)
        {
        {
                if (flags & O_APPEND)
                if (flags & O_APPEND)
                {
                {
                        pos = RdosGetFileSize(handle);
                        pos = RdosGetFileSize(handle);
                        RdosSetFilePos(handle, pos);
                        RdosSetFilePos(handle, pos);
                }
                }
 
 
                if (flags & O_TRUNC)
                if (flags & O_TRUNC)
                        RdosSetFileSize(handle, 0);
                        RdosSetFileSize(handle, 0);
 
 
                return handle;
                return handle;
        }
        }
        else
        else
                return -1;
                return -1;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.