Skip Menu |
 

This queue is for tickets about the Win32API-File CPAN distribution.

Report information
The Basics
Id: 61588
Status: new
Priority: 0/
Queue: Win32API-File

People
Owner: Nobody in particular
Requestors: patcat88 [...] snet.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.1101
Fixed in: (no value)



Subject: append open in OO interface fails to work, crude patch made
Download (untitled) / with headers
text/plain 725b
I tried to do an open using the OO interface, with append. The source code says ">>" should work. I include a test script. I got "Use of uninitialized value in subroutine entry at C:/Perl/site/lib/Win32API/File.pm line 658." No file was created. The handle was never made since the regexp left one of the >s still in the path. I am using Perl 5.10.0 Win32API:File 0.1101 . I made a crude patch to allow append to work with the OO interface. The patch has more info on the bugs. Show quoted text
__________________________________________________________ #!/usr/bin/perl -w use strict; use Win32API::File; my $file = new Win32API::File '>> C:\Documents and Settings\Owner\Desktop\somefile.txt'; $file->print('hello'.$$); $file->close();
Subject: file.pm.patch
Download file.pm.patch
text/x-diff 1.2k
--- file.pm.old 2008-11-17 19:11:46.000000000 -0500 +++ file.pm 2010-09-23 10:06:49.640625000 -0400 @@ -612,7 +612,9 @@ # FIXME: this needs to parse the full Perl open syntax in $expr my ($mixed, $mode, $path) = - ($expr =~ /^\s* (\+)? \s* (<|>|>>)? \s* (.*?) \s*$/x); + #in the open mode capture, '>' will evaluate and match before '>>' + #so order was reversed to test for '>>' first + ($expr =~ /^\s* (\+)? \s* (<|>>|>)? \s* (.*?) \s*$/x); croak "Unsupported open mode" if not $path; @@ -624,12 +626,22 @@ } elsif($mode eq '>') { $access = 'w'; } + #without this elsif createFile will truncate the file + elsif ($mode eq '>>') + { + $access = 'wk'; + } my $w32_handle = createFile($path, $access); $self->win32_handle($w32_handle); - $self->seek(1,2) if $append; + #why is position 1? it will just put in a \0 in the skipped char + #if I use the below line, I get "Not a GLOB reference at C:/Perl/lib/IO/Seekable.pm line 115." + #if $mode is '>>', why IDK, $self->seek works fine if $mode is '>' + #crude fix is to call Win32API::File's seek method directly without going through IO:: + #$self->seek(1,2) if $append; + SEEK($self, 0, 2) if $append; $self->_access($access); $self->_append($append);


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.