diff --git a/lib/WebGUI/Attachment.pm b/lib/WebGUI/Attachment.pm index a878b86b7..5484e6f74 100644 --- a/lib/WebGUI/Attachment.pm +++ b/lib/WebGUI/Attachment.pm @@ -307,9 +307,7 @@ sub getIcon { =cut sub getPath { - my ($slash); - $slash = ($^O =~ /Win/i) ? "\\" : "/"; - return $_[0]->{_node}->getPath.$slash.$_[0]->getFilename; + return $_[0]->{_node}->getPath.$session{os}{slash}.$_[0]->getFilename; } @@ -322,9 +320,8 @@ sub getPath { =cut sub getSize { - my ($size, $slash); - $slash = ($^O =~ /Win/i) ? "\\" : "/"; - my (@attributes) = stat($_[0]->{_node}->getPath.$slash.$_[0]->getFilename); + my ($size); + my (@attributes) = stat($_[0]->{_node}->getPath.$session{os}{slash}.$_[0]->getFilename); if ($attributes[7] > 1048576) { $size = round($attributes[7]/1048576); $size .= 'mb'; @@ -350,12 +347,10 @@ sub getSize { =cut sub getThumbnail { - my ($slash); - $slash = ($^O =~ /Win/i) ? "\\" : "/"; if ($hasImageMagick && isIn($_[0]->getType, qw(jpg jpeg gif png))) { - return $_[0]->{_node}->getURL.$slash.'thumb-'.$_[0]->getFilename; + return $_[0]->{_node}->getURL.'/thumb-'.$_[0]->getFilename; } elsif ($hasImageMagick && isIn($_[0]->getType, qw(tif tiff bmp))) { - return $_[0]->{_node}->getURL.$slash.'thumb-'.$_[0]->getFilename.'.png'; + return $_[0]->{_node}->getURL.'/thumb-'.$_[0]->getFilename.'.png'; } else { return ""; } @@ -446,9 +441,7 @@ sub new { =cut sub rename { - my ($slash); - $slash = ($^O =~ /Win/i) ? "\\" : "/"; - rename $_[0]->getPath, $_[0]->{_node}->getPath.$slash.$_[1]; + rename $_[0]->getPath, $_[0]->{_node}->getPath.$session{os}{slash}.$_[1]; $_[0]->{_filename} = $_[1]; } diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 8cbc35199..45131f763 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -122,9 +122,8 @@ sub _setupUserInfo { #------------------------------------------------------------------- sub _loadAuthentication { my ($dir, @files, $slash, $file, $cmd, $namespace, $exclude, @availableModules); - $slash = ($^O =~ /Win/i) ? "\\" : "/"; - $dir = $slash."lib".$slash."WebGUI".$slash."Authentication"; - opendir (DIR,$session{config}{webguiRoot}.$dir) or WebGUI::ErrorHandler::fatalError("Can't open Authentication module directory!"); + $dir = $session{config}{webguiRoot}.$session{os}{slash}."lib".$session{os}{slash}."WebGUI".$session{os}{slash}."Authentication"; + opendir (DIR,$dir) or WebGUI::ErrorHandler::fatalError("Can't open Authentication module directory!"); @files = readdir(DIR); foreach $file (@files) { if ($file =~ /(.*?)\.pm$/) { @@ -150,10 +149,9 @@ sub _loadAuthentication { #------------------------------------------------------------------- sub _loadMacros { - my ($slash, $namespace, $cmd, @files, $file, $dir, $exclude); - $slash = ($^O =~ /Win/i) ? "\\" : "/"; - $dir = $slash."lib".$slash."WebGUI".$slash."Macro"; - opendir (DIR,$session{config}{webguiRoot}.$dir) or WebGUI::ErrorHandler::fatalError("Can't open macro directory!"); + my ($namespace, $cmd, @files, $file, $dir, $exclude); + $dir = $session{config}{webguiRoot}.$session{os}{slash}."lib".$session{os}{slash}."WebGUI".$session{os}{slash}."Authentication"; + opendir (DIR,$dir) or WebGUI::ErrorHandler::fatalError("Can't open macro directory!"); @files = readdir(DIR); foreach $file (@files) { if ($file =~ /(.*?)\.pm$/) { @@ -173,10 +171,9 @@ sub _loadMacros { #------------------------------------------------------------------- sub _loadWobjects { - my ($dir, @files, $slash, $file, $cmd, $namespace, $exclude); - $slash = ($^O =~ /Win/i) ? "\\" : "/"; - $dir = $slash."lib".$slash."WebGUI".$slash."Wobject"; - opendir (DIR,$session{config}{webguiRoot}.$dir) or WebGUI::ErrorHandler::fatalError("Can't open wobject directory!"); + my ($dir, @files, $file, $cmd, $namespace, $exclude); + $dir = $session{config}{webguiRoot}.$session{os}{slash}."lib".$session{os}{slash}."WebGUI".$session{os}{slash}."Authentication"; + opendir (DIR,$dir) or WebGUI::ErrorHandler::fatalError("Can't open wobject directory!"); @files = readdir(DIR); foreach $file (@files) { if ($file =~ /(.*?)\.pm$/) { @@ -246,6 +243,16 @@ sub httpRedirect { sub open { my ($key, $config); ###---------------------------- + ### operating system specific things + $session{os}{name} = $^O; + if ($session{os}{name} =~ /^Win/i) { + $session{os}{type} = "Windowsish"; + $session{os}{slash} = "\\"; + } else { + $session{os}{type} = "Linuxish"; + $session{os}{slash} = "/"; + } + ###---------------------------- ### config variables $session{config}{webguiRoot} = $_[0]; $session{config}{configFile} = $_[1] || "WebGUI.conf"; diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index 0e5b5cd9d..87a5d489d 100644 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -29,8 +29,8 @@ print "\nWebGUI is checking your system environment:\n\n"; my ($os, $prereq, $dbi, $dbDrivers); $prereq = 1; -if ($^O =~ /Win/i) { - $os = "Microsoftish"; +if ($^O =~ /^Win/i) { + $os = "Windowsish"; } else { $os = "Linuxish"; }