[vorbis] Re: Problems with the pyvorbis Python wrapper under Windows

Csaba Henk ekho at renyi.hu
Tue May 20 01:16:05 PDT 2003



On Mon, 19 May 2003 andrew at andrewchatham.com wrote:

> Csaba,
> 
> 
> I'm actually on vacation right now (and I've never used the Windows
> version), but it wouldn't surprise me if I the fopen call on Windows
> behaves slightly differently than on unix. The comment editing code I
> mostly took from vorbiscomment program. It basically opens a new file,
> writes the comments, the copies everything over from the other file. It
> wouldn't surprise me if that doesn't work correctly in Windows, but I'm not
> sure if there's a workaround you can do without editing the C source. I'll
> look into it when I get back, though I won't really be able to test it.

I think the following patch for pyvorbis should solve the problem:

*<patch>********************

--- pyvorbis-1.2/src/pyvorbisinfo.c	2003-01-19 01:37:33.000000000 +0100
+++ pyvorbis-1.2-hacked/src/pyvorbisinfo.c	2003-05-20 10:13:29.000000000 +0200
@@ -1024,6 +1024,23 @@
   fclose(in_file);
   fclose(out_file);
 
+/* The following comment, quoted from the vorbiscomment/vcomment.c file
+ * of the vorbis-tools package, regards to, e.g., Windows:
+ * 
+ * Some platforms fail to rename a file if the new name already exists, so
+ * we need to remove, then rename. How stupid.
+ * 
+ * This is why the following block had to be inserted to make things work under
+ * Windows also.
+ * 
+ * <Csaba Henk (ekho at renyi.hu)>
+ */
+ 
+  if (remove(filename)) {
+    PyErr_SetFromErrno(PyExc_IOError);
+    return NULL;
+  }
+
   if (rename(tempfile, filename)) {
     PyErr_SetFromErrno(PyExc_IOError);
     return NULL;

*</patch>**********************************

<p><p>-- however, I neither can test it, as I can't compile it under Windows --
I tried to compile the py{ogg,vorbis} modules with Cygwin but it didn't
succed for first and it's not as important to me as to go deep into it.

Anyway, if you (anybody) will have Windows binaries for this patched
pyvorbis, I'd be glad to get one.

Csaba

<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 'vorbis-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 Vorbis mailing list