[xiph-cvs] cvs commit: vorbis-tools/vorbiscomment vcomment.c

Michael Smith msmith at xiph.org
Sat Jan 26 21:18:49 PST 2002



msmith      02/01/26 21:18:49

  Modified:    vorbiscomment vcomment.c
  Log:
  Workaround for cygwin bug where rename sometimes doesn't rename.

Revision  Changes    Path
1.20      +11 -2     vorbis-tools/vorbiscomment/vcomment.c

Index: vcomment.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/vcomment.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- vcomment.c	2002/01/27 04:35:46	1.19
+++ vcomment.c	2002/01/27 05:18:49	1.20
@@ -484,6 +484,15 @@
         if (p->out != NULL && p->out != stdout) fclose(p->out);
         if (p->com != NULL && p->com != stdout && p->com != stdin) fclose(p->com);
 
-	if(p->tempoutfile)
-		rename(p->outfilename, p->infilename);
+	if(p->tempoutfile) {
+        /* Some platforms fail to rename a file if the new name already exists,
+         * so we need to remove, then rename. How stupid.
+         */
+        if(remove(p->infilename)) 
+            fprintf(stderr, "Error removing old file %s\n", p->infilename);
+		if(rename(p->outfilename, p->infilename))
+            fprintf(stderr, "Error renaming %s to %s\n", p->outfilename, 
+                    p->infilename);
+    }
 }
+

<p><p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list