Padre
view release on metacpan or search on metacpan
lib/Padre/Util/FileBrowser.pm view on Meta::CPAN
}
return;
}
#
# private method for executing a process without waiting
#
sub _execute {
my ( $self, $exe_name, @cmd_args ) = @_;
my $result = undef;
require File::Which;
my $cmd = File::Which::which($exe_name);
if ( -e $cmd ) {
# On Windows, if we don't have STDIN/STDOUT, avoid IPC::Open3
# because it crashes when launching a non-console app
if (Padre::Constant::WIN32) {
# There is no actual waiting since cmd.exe starts explorer.exe and quits
require Padre::Util::Win32;
Padre::Util::Win32::ExecuteProcessAndWait(
directory => $self->{project},
file => 'cmd.exe',
parameters => "/C $cmd @cmd_args",
);
} else {
require IPC::Open2;
my $ok = eval {
my $r = '';
my $w = '';
my $pid = IPC::Open2::open2( $r, $w, $cmd, @cmd_args );
1;
};
if ( !$ok ) {
$result = $@;
}
}
} else {
$result = Wx::gettext("Failed to execute process\n");
}
return $result;
}
#
# Private method to execute a file in KDE or GNOME
#
sub _execute_unix {
die "Only to be called in UNIX!" unless Padre::Constant::UNIX;
my ( $self, $filename ) = @_;
my $error;
if ( defined $ENV{KDE_FULL_SESSION} ) {
# In KDE, execute: kfmclient exec $filename
$error = $self->_execute( 'kfmclient', "exec", $filename );
} elsif ( defined $ENV{GNOME_DESKTOP_SESSION_ID} ) {
# In Gnome, execute: nautilus --nodesktop --browser $filename
$error = $self->_execute( 'nautilus', "--no-desktop", "--browser", $filename );
} else {
$error = Wx::gettext("Could not find KDE or GNOME");
}
return $error;
}
1;
__END__
=pod
=head1 COPYRIGHT & LICENSE
Copyright 2008-2016 The Padre development team as listed in Padre.pm.
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
=cut
# Copyright 2008-2016 The Padre development team as listed in Padre.pm.
# LICENSE
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl 5 itself.
( run in 2.642 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )