| 1 | ############################################################################# | ||
| 2 | ## Name: Wx::Perl::FSHandler::UNC | ||
| 3 | ## Purpose: UNC FileSystemHandler | ||
| 4 | ## Author: Simon Flack | ||
| 5 | ## Modified by: $Author: mattheww $ on $Date: 2006/05/18 11:13:03 $ | ||
| 6 | ## Created: 14/11/2002 | ||
| 7 | ## RCS-ID: $Id: UNC.pm,v 1.8 2006/05/18 11:13:03 mattheww Exp $ | ||
| 8 | ############################################################################# | ||
| 9 | |||
| 10 | package Wx::Perl::FSHandler::UNC; | ||
| 11 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 1 | ▶ | use vars qw( @ISA $VERSION ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | @ISA = qw( Wx::PlFileSystemHandler ); | ||
| 15 | $VERSION = sprintf'%d.%03d', q$Revision: 1.8 $ =~ /: (\d+)\.(\d+)/; | ||
| 16 | |||
| 17 | 1 | ▶ | use IO::File; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 0 | ▶ | use Wx::FS; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 19 | |||
| 20 | sub CanOpen { | ||
| 21 | my ($self, $location) = @_; | ||
| 22 | (my $unc = $location) =~ s|/|\\|g; | ||
| 23 | |||
| 24 | return 1 if $unc =~ /^\\\\/; | ||
| 25 | } | ||
| 26 | |||
| 27 | sub OpenFile { | ||
| 28 | my ($self, $fs, $location) = @_; | ||
| 29 | (my $unc = $location) =~ s|/|\\|g; | ||
| 30 | |||
| 31 | return unless -e $unc && -r _; | ||
| 32 | |||
| 33 | my $mimetype = 'text/plain'; | ||
| 34 | my $anchor = ''; | ||
| 35 | |||
| 36 | my $fh = new IO::File( $unc, 'r' ); | ||
| 37 | return unless defined $fh; | ||
| 38 | |||
| 39 | my $FSfile = new Wx::FSFile( $fh, $unc, $mimetype, $anchor ); | ||
| 40 | return $FSfile; | ||
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | 1; | ||
| 45 | |||
| 46 | =pod | ||
| 47 | |||
| 48 | =head1 NAME | ||
| 49 | |||
| 50 | Wx::Perl::FSHandler::UNC - A filesystem handler for UNC filepaths | ||
| 51 | |||
| 52 | =head1 SYNOPSIS | ||
| 53 | |||
| 54 | use Wx::Perl::FSHandler::UNC; | ||
| 55 | Wx::FileSystemHandler::AddHandler( new Wx::Perl::FSHandler::UNC ); | ||
| 56 | |||
| 57 | =head1 DESCRIPTION | ||
| 58 | |||
| 59 | Wx::Perl::FSHandler::UNC is a wxFileSystemHandler. The default file system | ||
| 60 | handlers don't appear to support UNC file paths since the slashes are | ||
| 61 | un-microsoft'd by default. | ||
| 62 | |||
| 63 | =head1 WX SPECIFICS | ||
| 64 | |||
| 65 | See L</SYNOPSIS> for usage. | ||
| 66 | |||
| 67 | IO::File is used to open files given a UNC file path. | ||
| 68 | |||
| 69 | This module overrides two methods of wxFileSystemHandler: CanOpen() and | ||
| 70 | OpenFile(). | ||
| 71 | |||
| 72 | =head1 LIMITATIONS | ||
| 73 | |||
| 74 | This handler opens files only in read-only mode. | ||
| 75 | |||
| 76 | FindFirst() and FindNext() are not implemented. They will need to be if | ||
| 77 | wildcards are being used. | ||
| 78 | |||
| 79 | =head1 AUTHOR | ||
| 80 | |||
| 81 | Simon Flack <cpan _at_ bbc _dot_ co _dot_ uk> | ||
| 82 | |||
| 83 | =head1 SEE ALSO | ||
| 84 | |||
| 85 | wxWidgets: wxFileSystem, wxFSFile, wxFileSystemHandler, wxFileSystem Overview | ||
| 86 | |||
| 87 | wxPerl L<http://wxperl.sourceforge.net> | ||
| 88 | |||
| 89 | L<Win32::NetName> | ||
| 90 | |||
| 91 | L<Wx::Perl::FSHandler::LWP> | ||
| 92 | |||
| 93 | L<IO::File> | ||
| 94 | |||
| 95 | =head1 COPYRIGHT | ||
| 96 | |||
| 97 | (c) BBC 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL. | ||
| 98 | |||
| 99 | See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt | ||
| 100 | |||
| 101 | =cut | ||