[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: repository conversion on windows fails / binary file

From: Branko Čibej <brane_at_xbc.nu>
Date: 2002-06-12 00:43:59 CEST

Ryan Bloom wrote:

>>From: Greg Stein [mailto:gstein@lyra.org]
>>
>>On Tue, Jun 11, 2002 at 10:10:22PM +0200, Branko Cibej wrote:
>>
>>
>>>...
>>>The solution is to reopen the streams in binary mode, obviously. I
>>>wonder how you do that in APR.
>>>
>>>
>>Pass APR_BINARY to the apr_file_open() function. Not a problem.
>>
>>Of course, it appears that apr/file_io/win32/open.c doesn't even look
>>
>>
>for
>
>
>>that flag :-(
>>
>>
>
>That is a pretty major bug. :-(
>
>
>
>>Hmm. And reopening stdout/stdin in binary mode... oof. No fricking
>>
>>
>clue.
>
>We don't do that currently. You really only have two options as things
>stand today. 1) Close the file and re-open. 2) Implement
>apr_file_reopen (which devolves to option #1 in the worst case
>scenario).
>
>Ryan
>
>

/me has a more evil solution. Use apr_file_open_std*, as that bypasses
the CRT and uses the OS's file handles which don't know or care about
translation. The attached patch works on Win32.

Even if it's not the Totally Right Thing To Do, I vote we put it on
trunk/ and branches/fs-convert-2092/ and roll new tarballs, or at least
Win32 binaries.

-- 
Brane Čibej   <brane_at_xbc.nu>   http://www.xbc.nu/brane/

Index: ./main.c
===================================================================
--- ./main.c
+++ ./main.c 2002-06-12 00:36:10.000000000 +0200
@@ -17,6 +17,7 @@
  */
 
 
+#include <apr_file_io.h>
 #include "svnadmin.h"
 
 typedef enum svnadmin_cmd_t
@@ -467,6 +468,8 @@
     case svnadmin_cmd_dump:
       {
         svn_stream_t *stdout_stream, *stderr_stream;
+ apr_file_t *stdout_file, *stderr_file;
+ apr_status_t apr_err;
         svn_revnum_t
           lower = SVN_INVALID_REVNUM,
           upper = SVN_INVALID_REVNUM;
@@ -493,29 +496,51 @@
         
         /* Run the dump to STDOUT. Let the user redirect output into
            a file if they want. :-) Progress feedback goes to stderr. */
- stdout_stream = svn_stream_from_stdio (stdout, pool);
- stderr_stream = svn_stream_from_stdio (stderr, pool);
+ apr_err = apr_file_open_stdout (&stdout_file, pool);
+ if (apr_err)
+ INT_ERR (svn_error_createf (apr_err, 0, NULL, pool,
+ "%s: error opening stdout", argv[0]));
+ stdout_stream = svn_stream_from_aprfile (stdout_file, pool);
+
+ apr_err = apr_file_open_stderr (&stderr_file, pool);
+ if (apr_err)
+ INT_ERR (svn_error_createf (apr_err, 0, NULL, pool,
+ "%s: error opening stderr", argv[0]));
+ stderr_stream = svn_stream_from_aprfile (stderr_file, pool);
 
         INT_ERR (svn_repos_dump_fs (repos, stdout_stream, stderr_stream,
                                     lower, upper, pool));
 
- fflush(stdout);
+ apr_err = apr_file_flush(stdout_file);
+ if (apr_err)
+ INT_ERR (svn_error_createf (apr_err, 0, NULL, pool,
+ "%s: error flushing stdout", argv[0]));
       }
       break;
 
     case svnadmin_cmd_load:
       {
         svn_stream_t *stdin_stream, *stdout_stream;
+ apr_file_t *stdin_file, *stdout_file;
+ apr_status_t apr_err;
 
         INT_ERR (svn_repos_open (&repos, path, pool));
         fs = svn_repos_fs (repos);
 
         /* Read the stream from STDIN. Users can redirect a file. */
- stdin_stream = svn_stream_from_stdio (stdin, pool);
-
+ apr_err = apr_file_open_stdin (&stdin_file, pool);
+ if (apr_err)
+ INT_ERR (svn_error_createf (apr_err, 0, NULL, pool,
+ "%s: error opening stdin", argv[0]));
+ stdin_stream = svn_stream_from_aprfile (stdin_file, pool);
+
         /* Have the parser dump feedback to STDOUT. */
- stdout_stream = svn_stream_from_stdio (stdout, pool);
-
+ apr_err = apr_file_open_stdout (&stdout_file, pool);
+ if (apr_err)
+ INT_ERR (svn_error_createf (apr_err, 0, NULL, pool,
+ "%s: error opening stdout", argv[0]));
+ stdout_stream = svn_stream_from_aprfile (stdout_file, pool);
+
         INT_ERR (svn_repos_load_fs (repos, stdin_stream, stdout_stream, pool));
       }
       break;

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Jun 12 00:44:33 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.