Dirk wrote:
Dirk schrieb:

I wonder if File::Copy allows some sort of "hook" so that we can process each "chunk" on the fly to do this conversion? Otherwise it may be necessary to create an intermediate file in order to perform the conversion prior to the final copy to the dumpfile...
Hello Toby,

this is where my PERL knowledge completely stops. At this point I would start an external converter to do the job ;-). As far as I have seen this copy patch, but wouldn't be a block read and block write perform a similar functionality? Somewehere I read, that you can set filters on streams in PERL. So wouldn't be a chuncked implementation of the copy with a CR+LF input stream and a LF output stream also do the job?
A quick galnce into the doucmentation: http://perldoc.perl.org/File/Copy.html

*Note that passing in files as handles instead of names may lead to loss of information on some operating systems; it is recommended that you use file names whenever possible.* Files are opened in binary mode where applicable. To get a consistent behaviour when copying from a filehandle to a file, use |binmode <http://perldoc.perl.org/functions/binmode.html>| on the filehandle.

So wouldn't something like:

   if(!defined $text && defined $file) {
if ($node->get_prop('svn:mime-type') == 'application/octet-stream');
          open ($input, "<:crlf", $file)
       } else {
          open ($input, "<", $file);
          binmode ($input);
       }
             copy($input, $fh);
       print $fh "\n";
   }

Wow, I had never even heard of these filehandle "layers". See, you have taught me some new Perl tricks :)

After doing some more experimentation I have found that the File::Copy does not seem to respect these layers at all, but that the following code works on both Windows and *nix to do the translation while copying from one filehandle to the other:

  if(!defined $text && defined $file) {
      if ($node->get_prop('svn:mime-type') == 'application/octet-stream');
          open ($input, "<:crlf", $file);

           while(<$input>) {
               print $fh $_;
           }

      } else {
          open ($input, "<", $file);
          binmode ($input);
          copy($input, $fh);
      }

      close $input;
      print $fh "\n";
  }

I'm sure that the "while(<$input>)" is probably not as efficient as File::Copy, but it will at least be buffered by the Perl I/O routines and at any rate it is still reading only one line at a time, so it will not suffer the memory issues of reading in the whole contents as we did before.

toby

_______________________________________________
vss2svn-users mailing list
Project homepage:
http://www.pumacode.org/projects/vss2svn/
Subscribe/Unsubscribe/Admin:
http://lists.pumacode.org/mailman/listinfo/vss2svn-users-lists.pumacode.org
Mailing list web interface (with searchable archives):
http://dir.gmane.org/gmane.comp.version-control.subversion.vss2svn.user

Reply via email to