Bladeren bron

Added sys_rename

ceriel 36 jaren geleden
bovenliggende
commit
40b8726ecd
4 gewijzigde bestanden met toevoegingen van 33 en 4 verwijderingen
  1. 1 0
      modules/src/system/.distr
  2. 2 2
      modules/src/system/Makefile
  3. 15 0
      modules/src/system/rename.c
  4. 15 2
      modules/src/system/system.3

+ 1 - 0
modules/src/system/.distr

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

+ 2 - 2
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)

+ 15 - 0
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;
+}
+

+ 15 - 2
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