Discussion:
Win32-FileOp and Map
(too old to reply)
pit
2014-12-09 14:42:48 UTC
Permalink
Hi Folks,

I know, thats not the right place for this question, but I hope someone can help me.

I want to map a network drive with Win32-FileOp->Map. With the version 0.14.1 under WinXP it works. Under Win7 with the version 0.16.02 it doesn't work.

Any idea ?

Thanks
Pit
$Bill
2014-12-09 20:00:24 UTC
Permalink
Post by pit
Hi Folks,
I know, thats not the right place for this question, but I hope someone can help me.
I want to map a network drive with Win32-FileOp->Map. With the version 0.14.1 under WinXP it works. Under Win7 with the version 0.16.02 it doesn't work.
Any idea ?
How about a bit more info. Which croak is it hitting? Debug it
if you have to to see where it's erring off. Also what arguments
did you call it with? A very small failing script snippet would
be in order for others to try.
pit
2014-12-10 09:22:01 UTC
Permalink
Post by $Bill
Post by pit
Hi Folks,
I know, thats not the right place for this question, but I hope someone can help me.
I want to map a network drive with Win32-FileOp->Map. With the version 0.14.1 under WinXP it works. Under Win7 with the version 0.16.02 it doesn't work.
Any idea ?
How about a bit more info. Which croak is it hitting? Debug it
if you have to to see where it's erring off. Also what arguments
did you call it with? A very small failing script snippet would
be in order for others to try.
Here my code snippet

$map = Win32::FileOp::Map($drive => $share, {persistent=>0,overwrite=>0});

$drive = "T:"
$share = "\\phlinux\usr2\"

after that $map is undefined.

Pit
$Bill
2014-12-11 00:33:19 UTC
Permalink
Post by pit
Here my code snippet
$map = Win32::FileOp::Map($drive => $share, {persistent=>0,overwrite=>0});
$drive = "T:"
$share = "\\phlinux\usr2\"
after that $map is undefined.
That's not an actual code snippet that's been run and failed.

I tried a similar script and got undef returned (see below):
------------------------------------------------------------
use strict;
use warnings;
use Win32::FileOp;

my $drive = "T:";
# my $share = "\\phlinux\usr2\"; # not proper quoting
my $share = "//home/dbe";
my $map = Win32::FileOp::Map($drive => $share, { persistent => 0,
overwrite => 0} );
printf "map='%s' GLE='%s' ($^E)\n", $map || 'undef', Win32::GetLastError();

__END__
------------------------------------------------------------

Then I looked at the Map sub and changed line 1432 from:
return;
to:
return $res;

And I got the following output from above script:

map='66' GLE='66' (The network resource type is not correct)

So that looks like a bug.

The problem is I don't have the 0.16.02 version, I have the 0.14.1 version
which appears to have the above bug in it - which you could always change
like I just did.

Check the code in your newer version and see what this part looks like
(starting around line 1423):

if ($res = $Win32::FileOp::WNetAddConnection3->Call( $handle, $struct, $passwd, $username, $options)) {
if (($res == 1202 or $res == 85) and ($opt->{overwrite} or $opt->{force_overwrite})) {
Unmap($disk,{force => $opt->{force_overwrite}})
or return;
$Win32::FileOp::WNetAddConnection3->Call( $handle, $struct, $passwd, $username, $options)
and return;
} elsif ($res == 997) { # Overlapped I/O operation is in progress.
return 1;
} else {
return $res; # line I changed $Bill 1432 - looks like 1581 in 0.16.02
}
}

If it has the same line at what looks like 1581 on CPAN, try changing it like I did
and see what you get. This time use a real test script that has code that actually
was run and failed like mine.

Loading...