Added sys_rename

This commit is contained in:
ceriel 1988-06-28 11:12:18 +00:00
parent d702321c37
commit c03e25dc0d
4 changed files with 33 additions and 4 deletions

View file

@ -10,6 +10,7 @@ modtime.c
open.c open.c
read.c read.c
remove.c remove.c
rename.c
stop.c stop.c
system.3 system.3
system.c system.c

View file

@ -8,10 +8,10 @@ CFLAGS = $(INCLUDES) -O
AR = ar AR = ar
OBJ = access.o break.o chmode.o close.o create.o filesize.o \ OBJ = access.o break.o chmode.o close.o create.o filesize.o \
modtime.o lock.o open.o read.o remove.o stop.o \ modtime.o lock.o open.o read.o remove.o stop.o \
system.o time.o unlock.o write.o seek.o system.o time.o unlock.o write.o seek.o rename.o
CSRC = access.c break.c chmode.c close.c create.c filesize.c \ CSRC = access.c break.c chmode.c close.c create.c filesize.c \
modtime.c lock.c open.c read.c remove.c stop.c \ modtime.c lock.c open.c read.c remove.c stop.c \
system.c time.c unlock.c write.c seek.c system.c time.c unlock.c write.c seek.c rename.c
SRC = Makefile system.h $(CSRC) SRC = Makefile system.h $(CSRC)
all: $(LIBSYS) all: $(LIBSYS)

View file

@ -0,0 +1,15 @@
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
int
sys_rename(path1, path2)
char *path1, *path2;
{
unlink(path2);
return link(path1, path2) == 0 &&
unlink(path1) == 0;
}

View file

@ -2,7 +2,7 @@
.ad .ad
.SH NAME .SH NAME
sys_open, sys_close, sys_read, sys_write, sys_reset, sys_access, sys_open, sys_close, sys_read, sys_write, sys_reset, sys_access,
sys_modtime, sys_remove, sys_filesize, sys_chmode, sys_modtime, sys_remove, sys_rename, sys_filesize, sys_chmode,
sys_lock, sys_unlock, sys_lock, sys_unlock,
sys_break, sys_stop, sys_time \- system call interface sys_break, sys_stop, sys_time \- system call interface
.SH SYNOPSIS .SH SYNOPSIS
@ -45,6 +45,9 @@ sys_break, sys_stop, sys_time \- system call interface
.B int sys_remove(path) .B int sys_remove(path)
.B char *path; .B char *path;
.PP .PP
.B int sys_rename(path1, path2)
.B char *path1, *path2;
.PP
.B long sys_filesize(path) .B long sys_filesize(path)
.B char *path; .B char *path;
.PP .PP
@ -218,6 +221,15 @@ is performed on it.
A non-zero return value indicates successful action whereas 0 A non-zero return value indicates successful action whereas 0
indicates that the given file does not exist or cannot be removed. indicates that the given file does not exist or cannot be removed.
.PP .PP
.I Sys_rename
renames file
.I path1
to
.IR path2 .
A non-zero return value indicates successful action. If
.I path2
exists, it is removed first.
.PP
The function The function
.I sys_filesize .I sys_filesize
returns the size in bytes of the returns the size in bytes of the
@ -292,7 +304,8 @@ The routines
.IR sys_read , .IR sys_read ,
.IR sys_write , .IR sys_write ,
.IR sys_reset , .IR sys_reset ,
.I sys_chmode .IR sys_chmode ,
.IR sys_rename ,
and and
.I sys_remove .I sys_remove
return a value of zero upon any failure and a non-zero return a value of zero upon any failure and a non-zero