3 =head1 NAME $RCSfile: OSDep.pm,v $
5 Isolate OS dependencies
13 Andrew DeFaria <Andrew@ClearSCM.com>
21 Tue Jan 3 11:36:10 PST 2006
25 $Date: 2011/11/16 19:46:13 $
31 This module seeks to isolate OS dependences by confining them to this
32 module as well as provide convienent references and mechanisms for
33 doing things that are different on different OSes.
35 print "Running on $ARCH\n";
37 my $filename = $app_base . $SEPARATOR . "datafile.txt";
41 This module exports several variables that are useful to isolate OS
42 dependencies. For example, $ARCH is set to "windows", "cygwin" or the
43 value of $^O depending on which OS the script is running. This allows
44 you to write code that is dependant on which OS you are running
45 on. Similarly, $NULL is set to the string "NUL" when running on
46 Windows otherwise it is set to "/dev/null" (Under Cygwin /dev/null is
47 appropriate). This way if you wish to say redirect output to "null"
50 There is currently only one subroutine exported, Chrooted, which
51 returns $TRUE if you are operating in a chrooted environment, $FALSE
56 The following routines are exported:
67 our $ARCH = $^O =~ /MSWin/
72 our $NULL = $^O =~ /MSWin/ ? 'NUL' : '/dev/null';
73 our $SEPARATOR = $^O =~ /MSWin/ ? '\\' : '/';
76 our $ROOT = $^O =~ /MSWin/ ? $ENV {SYSTEMDRIVE} . $SEPARATOR : "/";
93 Returns $TRUE if you are operating under a chrooted environment,
138 if ($ARCH eq "windows" or $ARCH eq "cygwin") {
139 # Not sure how this relates to Windows/Cygwin environment so just
143 return ((stat $ROOT) [1] != 2);
157 Set to either "windows", "cygwin" or $^O.
161 Set to "NUL" for Windows, "/dev/null" otherwise.
165 Set to "\" for Windows, "/" otherwise.
169 Convenient boolean variable set to 1 (Cause I always forget if 1 or 0
174 Convenient boolean variable set to 0 (Cause I always forget if 1 or 0
179 Set to SYSTEMDRIVE for Windows, "/" otherwise
187 =head1 INCOMPATABILITIES
191 =head1 BUGS AND LIMITATIONS
193 There are no known bugs in this module.
195 Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
197 =head1 LICENSE AND COPYRIGHT
199 This Perl Module is freely available; you can redistribute it and/or
200 modify it under the terms of the GNU General Public License as
201 published by the Free Software Foundation; either version 2 of the
202 License, or (at your option) any later version.
204 This Perl Module is distributed in the hope that it will be useful,
205 but WITHOUT ANY WARRANTY; without even the implied warranty of
206 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
207 General Public License (L<http://www.gnu.org/copyleft/gpl.html>) for more
210 You should have received a copy of the GNU General Public License
211 along with this Perl Module; if not, write to the Free Software Foundation,
212 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.