11
Zim::Win32 - win32 specific routines for zim
15
This module contains some routines that are specific
16
for the windows platform.
20
## Spawning processes ##
22
$Zim::GUI::DEFAULTS{browser} = 'firefox.exe';
23
$Zim::GUI::DEFAULTS{file_browser} = 'explorer.exe';
25
*Zim::GUI::Component::_exec = sub {
26
my ($self, @args) = @_;
29
$cmdline = join ' ', map {/\s/ ? qq/"$_"/ : $_} @args;
34
$args[0] =~ /^(['"])(.+?)\1|^(\S+)/;
37
$prog = _lookup_exec($self, $prog) unless $prog =~ /\\/;
40
warn "Executing $prog, $cmdline\n";
42
Win32::Process::Create(
43
$ProcessObj, $prog, $cmdline, 0, NORMAL_PRIORITY_CLASS, "." );
47
my ($self, $prog) = @_;
48
for (split /;/, $ENV{PATH}) {
49
my $try = File::Spec->catfile($_, $prog);
50
return $try if -f $try;
52
return $self->error_dialog("Could not find program: $prog");
55
## File name parsing ##
58
my $_abs_path = *Zim::File::abs_path{CODE};
59
my $_parse_uri = *Zim::File::parse_uri{CODE};
61
# Turn /foo into C:/foo
62
# wrap unix abs_path function by using /C:/path
64
*Zim::File::abs_path = sub {
65
my ($class, $file, $ref) = @_;
67
if ($file =~ m#file:/#) { $file = $class->parse_uri($file) }
68
else { $file =~ s#\\#/#g } # foo\bar => foo/bar
70
$file =~ s#^([a-z]:/)#/$1#i; # C:/foo => /C:/foo
71
$file = $_abs_path->($class, $file, $ref);
72
$file =~ s#^/+([a-z]:/)#$1#i; # /C:foo => C:/foo
74
return $file unless $file =~ m#^/#i;
77
my ($vol, undef, undef) = File::Spec->splitpath($ref);
81
# support file:///C:/path
82
# translate file:////host/share => smb://host/share
84
*Zim::File::parse_uri = sub {
87
$file =~ m#^file:/# or return $file;
88
return $file if $file =~ s#^file:////(?!/)#smb://#;
89
$file = $_parse_uri->($class, $file);
90
$file =~ s#^/+([a-z]:/)#$1#i;
94
*Zim::File::localize = sub {
96
if ($file =~ s#^smb://+##) { $file = '\\\\'.$file }
97
elsif ($file =~ m#^\w[\w\+\-\.]+:/#) { return $file }
98
elsif ($file =~ m#^/#) {
100
my ($vol, undef, undef) = File::Spec->splitpath($cwd);
113
Jaap Karssenberg (Pardus) E<lt>pardus@cpan.orgE<gt>
115
Copyright (c) 2006 Jaap G Karssenberg. All rights reserved.
116
This program is free software; you can redistribute it and/or
117
modify it under the same terms as Perl itself.