From c03e25dc0dcab16ddbe393fa58d7c29f71df0f18 Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 28 Jun 1988 11:12:18 +0000 Subject: [PATCH] Added sys_rename --- modules/src/system/.distr | 1 + modules/src/system/Makefile | 4 ++-- modules/src/system/rename.c | 15 +++++++++++++++ modules/src/system/system.3 | 17 +++++++++++++++-- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 modules/src/system/rename.c diff --git a/modules/src/system/.distr b/modules/src/system/.distr index b4e192629..1d02945b9 100644 --- a/modules/src/system/.distr +++ b/modules/src/system/.distr @@ -10,6 +10,7 @@ modtime.c open.c read.c remove.c +rename.c stop.c system.3 system.c diff --git a/modules/src/system/Makefile b/modules/src/system/Makefile index 0b40ba7e8..1e068e9f2 100644 --- a/modules/src/system/Makefile +++ b/modules/src/system/Makefile @@ -8,10 +8,10 @@ CFLAGS = $(INCLUDES) -O AR = ar 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 \ - 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 \ 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) all: $(LIBSYS) diff --git a/modules/src/system/rename.c b/modules/src/system/rename.c new file mode 100644 index 000000000..cd2f0c17d --- /dev/null +++ b/modules/src/system/rename.c @@ -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; +} + diff --git a/modules/src/system/system.3 b/modules/src/system/system.3 index 38bd8888c..9adab8339 100644 --- a/modules/src/system/system.3 +++ b/modules/src/system/system.3 @@ -2,7 +2,7 @@ .ad .SH NAME 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_break, sys_stop, sys_time \- system call interface .SH SYNOPSIS @@ -45,6 +45,9 @@ sys_break, sys_stop, sys_time \- system call interface .B int sys_remove(path) .B char *path; .PP +.B int sys_rename(path1, path2) +.B char *path1, *path2; +.PP .B long sys_filesize(path) .B char *path; .PP @@ -218,6 +221,15 @@ is performed on it. A non-zero return value indicates successful action whereas 0 indicates that the given file does not exist or cannot be removed. .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 .I sys_filesize returns the size in bytes of the @@ -292,7 +304,8 @@ The routines .IR sys_read , .IR sys_write , .IR sys_reset , -.I sys_chmode +.IR sys_chmode , +.IR sys_rename , and .I sys_remove return a value of zero upon any failure and a non-zero