Author: dylan
Date: 2004-12-28 02:49:53 -0500 (Tue, 28 Dec 2004)
New Revision: 434
Modified:
trunk/main/core/lib/Haver/OS/BSD.pm
trunk/main/core/lib/Haver/OS/Unix.pm
trunk/main/core/lib/Haver/OS/Win32.pm
trunk/main/core/lib/Haver/OS/Win95.pm
trunk/main/core/lib/Haver/OS/WinNT.pm
Log:
config_find is removed because it was a hack.
Modified: trunk/main/core/lib/Haver/OS/BSD.pm
===================================================================
--- trunk/main/core/lib/Haver/OS/BSD.pm 2004-12-28 07:46:45 UTC (rev 433)
+++ trunk/main/core/lib/Haver/OS/BSD.pm 2004-12-28 07:49:53 UTC (rev 434)
@@ -20,10 +20,7 @@
use warnings;
use base qw(Haver::OS::Unix);
-our $VERSION = 0.01;
-our %Path;
+our $VERSION = 0.02;
-sub confdir { '/etc/local' }
-
1;
Modified: trunk/main/core/lib/Haver/OS/Unix.pm
===================================================================
--- trunk/main/core/lib/Haver/OS/Unix.pm 2004-12-28 07:46:45 UTC (rev
433)
+++ trunk/main/core/lib/Haver/OS/Unix.pm 2004-12-28 07:49:53 UTC (rev
434)
@@ -56,57 +56,8 @@
}
}
-sub config_find {
- my ($this, %arg) = @_;
- my $scope = $arg{scope} || 'user';
- my $type = $arg{type} || 'file';
- my $result;
-
- croak "name => 'appname' required" unless exists $arg{name};
-
-
- if ($scope eq 'global') {
- my $etc = $this->confdir;
- if ($type eq 'file') {
- $result = "$etc/$arg{name}rc";
- } elsif ($type eq 'dir') {
- $result = "$etc/$arg{name}";
- } else {
- croak "type => '$arg{type}' is an unknown type";
- }
- } elsif ($scope eq 'user' or $scope eq 'local') {
- my $home = $this->homedir;
- if ($type eq 'file') {
- $result = "$home/.$arg{name}rc";
- } elsif ($type eq 'dir') {
- $result = "$home/.$arg{name}";
- } else {
- croak "type => '$arg{type}' is an unknown type";
- }
- } elsif ($scope eq 'global-data') {
- $type = 'dir';
- $result = $this->datadir . "/$arg{name}";
- } else {
- croak "scope => '$arg{scope}' is an unknown scope";
- }
-
-
- $this->make_path(path => $result, type => $type) unless $arg{no_mkpath};
-
-
- return $result;
-
-}
-
-sub home { shift->homedir }
+sub home { $ENV{HOME} }
sub user_is_root { $> == 0 ? 1 : 0 }
sub family { 'Unix' }
-
-
-sub confdir { '/etc' }
-sub homedir { $ENV{HOME} }
-sub datadir { '/var/lib' }
-
-
1;
Modified: trunk/main/core/lib/Haver/OS/Win32.pm
===================================================================
--- trunk/main/core/lib/Haver/OS/Win32.pm 2004-12-28 07:46:45 UTC (rev
433)
+++ trunk/main/core/lib/Haver/OS/Win32.pm 2004-12-28 07:49:53 UTC (rev
434)
@@ -19,26 +19,13 @@
use strict;
use warnings;
-our $VERSION = 0.01;
+our $VERSION = 0.02;
use Win32;
-use Win32::TieRegistry (TiedRef => '$WinReg');
sub current_user {
Win32::LoginName();
}
-{
- my $progdir;
- sub program_files {
- return $progdir if defined $progdir;
- $progdir = $WinReg->{
- 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows'
- . '\CurrentVersion\ProgramFilesDir'
- };
- }
-}
-
-
sub family { 'Windows' }
Modified: trunk/main/core/lib/Haver/OS/Win95.pm
===================================================================
--- trunk/main/core/lib/Haver/OS/Win95.pm 2004-12-28 07:46:45 UTC (rev
433)
+++ trunk/main/core/lib/Haver/OS/Win95.pm 2004-12-28 07:49:53 UTC (rev
434)
@@ -24,25 +24,10 @@
use base 'Haver::OS::Win32';
use File::Spec;
-my $WinReg;
+my $Reg;
our $VERSION = 0.01;
-use Win32::TieRegistry (TiedHash => \$WinReg);
+use Win32::TieRegistry (TiedHash => \$Reg);
-
-sub init_path {
- my $progdir = $WinReg->{
- 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows'
- . '\CurrentVersion\ProgramFilesDir'
- };
-}
-
-sub config_find {
- my ($this, %arg) = @_;
- my $scope = $arg{scope} || 'user';
-
- die "unimplemented";
-}
-
sub user_is_root { return undef } # No such thing as root on 9x.
1;
Modified: trunk/main/core/lib/Haver/OS/WinNT.pm
===================================================================
--- trunk/main/core/lib/Haver/OS/WinNT.pm 2004-12-28 07:46:45 UTC (rev
433)
+++ trunk/main/core/lib/Haver/OS/WinNT.pm 2004-12-28 07:49:53 UTC (rev
434)
@@ -22,74 +22,11 @@
use Carp;
use Haver::OS::Win32;
use base 'Haver::OS::Win32';
-use Win32;
-use Win32::TieRegistry ( TiedRef => '$Reg', Delimiter => '/' );
+#use Win32;
+#use Win32::TieRegistry ( TiedRef => '$Reg', Delimiter => '/' );
-our $VERSION = 0.01;
-my %Dirs = ();
+our $VERSION = 0.02;
-sub config_find {
- my ($this, %arg) = @_;
- my $scope = $arg{scope} || 'user';
- my $type = $arg{type} || 'file';
- my $result;
-
- croak "name => 'appname' required" unless exists $arg{name};
-
- my $name = join(' ', map ucfirst, split(/[-_ ]/, $arg{name}));
- my $programs = $this->program_files;
-
- if ($scope eq 'global') {
- if ($type eq 'file') {
- $result = "$programs\\$name\\config.txt";
- } elsif ($type eq 'dir') {
- $result = "$programs\\$name";
- } else {
- croak "type => '$arg{type}' is an unknown type";
- }
- } elsif ($scope eq 'user') {
- my $dir = $Dirs{appdata};
-
- if ($type eq 'file') {
- $result = "$dir\\$name\\config.txt";
- } elsif ($type eq 'dir') {
- $result = "$dir\\$name";
- } else {
- croak "type => '$arg{type}' is an unknown type";
- }
- } elsif ($scope eq 'data') {
- if ($type eq 'file') {
- $result = "$programs\\$name\\data.dat";
- } elsif ($type eq 'dir') {
- $result = "$programs\\$name\\data";
- } else {
- croak "type => '$arg{type}' is an unknown type";
- }
- } else {
- croak "scope => '$arg{scope}' is an unknown scope";
- }
-
-
- $this->make_path(path => $result, type => $type) unless $arg{no_mkpath};
- return $result;
-}
-
-
-sub setup_dirs {
- return if %Dirs;
-
- my $usf =
'CUser/Software/Microsoft/Windows/CurrentVersion/Explorer/User Shell Folders/';
- my $f = $Reg->{$usf};
-
- $Dirs{personal} = $f->{'/Personal'};
- $Dirs{appdata} = $f->{'/AppData'};
- $Dirs{local_appdata} = $f->{'/Local AppData'};
-
- foreach my $key (keys %Dirs) {
- $Dirs{$key} = Win32::ExpandEnvironmentStrings($Dirs{$key});
- }
-}
-
sub user_is_root {
my $val = Win32::IsAdminUser();
return 0 if not defined $val;
@@ -100,7 +37,4 @@
return $Dirs{personal};
}
-
-setup_dirs();
-
1;