Implement append redirection in wcmd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ChangeLog: Implement >> style (append) output redirection in wcmd.

Index: programs/wcmd/wcmdmain.c
===================================================================
RCS file: /home/wine/wine/programs/wcmd/wcmdmain.c,v
retrieving revision 1.36
diff -u -r1.36 wcmdmain.c
--- programs/wcmd/wcmdmain.c	5 Sep 2003 23:15:42 -0000	1.36
+++ programs/wcmd/wcmdmain.c	10 Sep 2003 15:31:03 -0000
@@ -258,7 +258,7 @@
 {
     char *cmd, *p;
     int status, i, len;
-    DWORD count;
+    DWORD count, creationDisposition;
     HANDLE old_stdin = 0, old_stdout = 0, h;
     char *whichcmd;
     SECURITY_ATTRIBUTES sa;
@@ -307,16 +307,27 @@
       SetStdHandle (STD_INPUT_HANDLE, h);
     }
     if ((p = strchr(cmd,'>')) != NULL) {
-      h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_WRITE, 0, &sa, CREATE_ALWAYS,
+      *p++ = '\0';
+      if ('>' == *p) {
+        creationDisposition = OPEN_ALWAYS;
+        p++;
+      }
+      else {
+        creationDisposition = CREATE_ALWAYS;
+      }
+      h = CreateFile (WCMD_parameter (p, 0, NULL), GENERIC_WRITE, 0, &sa, creationDisposition,
 		FILE_ATTRIBUTE_NORMAL, NULL);
       if (h == INVALID_HANDLE_VALUE) {
 	WCMD_print_error ();
         HeapFree( GetProcessHeap(), 0, cmd );
 	return;
       }
+      if (SetFilePointer (h, 0, NULL, FILE_END) ==
+          INVALID_SET_FILE_POINTER) {
+        WCMD_print_error ();
+      }
       old_stdout = GetStdHandle (STD_OUTPUT_HANDLE);
       SetStdHandle (STD_OUTPUT_HANDLE, h);
-      *--p = '\0';
     }
     if ((p = strchr(cmd,'<')) != NULL) *p = '\0';
 


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux