From 36da77056776b6a84470fe7a3665077943f846b9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 8 Aug 2012 16:04:53 +0200 Subject: [PATCH] =?utf8?q?Modul=20"SL::System::Process"=20f=C3=BCr=20syste?= =?utf8?q?m-relevante=20Befehle?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Wie z.B. einer Funktion, die den absoluten Pfad zu den Kivitendo-Programmdateien zurückliefert. --- SL/System/Process.pm | 61 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 SL/System/Process.pm diff --git a/SL/System/Process.pm b/SL/System/Process.pm new file mode 100644 index 000000000..0bddfd6b3 --- /dev/null +++ b/SL/System/Process.pm @@ -0,0 +1,61 @@ +package SL::System::Process; + +use strict; + +use parent qw(Rose::Object); + +use English qw(-no_match_vars); +use File::Spec; +use File::Basename; + +sub exe_dir { + my $dir = dirname(File::Spec->rel2abs($PROGRAM_NAME)); + my $system_dir = File::Spec->catdir($dir, 'SL', 'System'); + return $dir if -d $system_dir && -f File::Spec->catfile($system_dir, 'TaskServer.pm'); + + my @dirs = reverse File::Spec->splitdir($dir); + shift @dirs; + $dir = File::Spec->catdir(reverse @dirs); + $system_dir = File::Spec->catdir($dir, 'SL', 'System'); + return File::Spec->curdir unless -d $system_dir && -f File::Spec->catfile($system_dir, 'TaskServer.pm'); + + return $dir; +} + +1; +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::System::Process - assorted system-relevant functions + +=head1 SYNOPSIS + + # Get base path to Kivitendo scripts + my $path = SL::System::Process->exe_dir; + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns the absolute path to the directory the Kivitendo executables +(C etc.) and modules (sub-directory C etc.) are located +in. + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Moritz Bunkus Em.bunkus@linet-services.deE + +=cut -- 2.20.1