file_demo.c
changeset 138 dff18d1ac2af
parent 131 b5ad49852adc
--- a/file_demo.c
+++ b/file_demo.c
@@ -10,6 +10,9 @@
 #include <string.h>
 #include <fcntl.h>
 
+#define TESTFILE1 "/tmp/test1.txt"
+#define TESTFILE2 "/tmp/test2.txt"
+
 int main (int argc, char **argv)
 {
     int fd1;
@@ -18,20 +21,20 @@
 
     char *str = "Schreib mal was!";
 
-    if (argc != 2)
+    if (argc != 2) {
+        printf ("Usage: %s <MODE>\n", argv[0]);
         return -1;
+    }
     mode = strtoul (argv[1], NULL, 8);
 
-    if (system ("/bin/rm -f /home/mbroeker/Desktop/test1.txt") != 0)
-        return EXIT_FAILURE;
-    if (system ("/bin/rm -f /home/mbroeker/Desktop/test2.txt") != 0)
-        return EXIT_FAILURE;
+    unlink (TESTFILE1);
+    unlink (TESTFILE2);
 
     /*
      * Opens ReadOnly
      */
-    fd1 = open ("/home/mbroeker/Desktop/test1.txt", O_CREAT, mode);
-    fd2 = open ("/home/mbroeker/Desktop/test2.txt", O_RDWR | O_CREAT, mode);
+    fd1 = open (TESTFILE1, O_CREAT, mode);
+    fd2 = open (TESTFILE2, O_RDWR | O_CREAT, mode);
 
     if (fd1)
         if (write (fd1, str, strlen (str)) == -1)