| 1 | #!/usr/bin/perl -w |
1 | ################################################################################ |
|
|
2 | # WeBWorK xmlrpc (c) 2000-2002 WeBWorK Project |
|
|
3 | # $Id$ |
|
|
4 | ################################################################################ |
|
|
5 | |
|
|
6 | package WeBWorK::PG::IO; |
| 2 | |
7 | |
| 3 | use strict; |
8 | use strict; |
|
|
9 | use warnings; |
|
|
10 | use Exporter; |
| 4 | |
11 | |
|
|
12 | our @ISA = qw(Exporter); |
|
|
13 | our @EXPORT = qw( |
|
|
14 | includePGtext |
|
|
15 | send_mail_to |
|
|
16 | read_whole_problem_file |
|
|
17 | read_whole_file |
|
|
18 | convertPath |
|
|
19 | getDirDelim |
|
|
20 | getCourseTempDirectory |
|
|
21 | surePathToTmpFile |
|
|
22 | fileFromPath |
|
|
23 | directoryFromPath |
|
|
24 | createFile |
|
|
25 | createDirectory |
|
|
26 | REMOTE_HOST |
|
|
27 | REMOTE_ADDR |
|
|
28 | ); |
|
|
29 | |
|
|
30 | |
| 5 | =head2 Private functions (not methods) used by PGtranslator for file IO. |
31 | =head2 Private functions (not methods) used by PGtranslator for file IO. |
| 6 | |
32 | |
| 7 | |
|
|
| 8 | |
|
|
| 9 | =cut |
33 | =cut |
| 10 | |
34 | |
| 11 | my $REMOTE_HOST = (defined( $ENV{'REMOTE_HOST'} ) ) ? $ENV{'REMOTE_HOST'}: 'unknown host'; |
35 | our $REMOTE_HOST = (defined( $ENV{'REMOTE_HOST'} ) ) ? $ENV{'REMOTE_HOST'}: 'unknown host'; |
| 12 | my $REMOTE_ADDR = (defined( $ENV{'REMOTE_ADDR'}) ) ? $ENV{'REMOTE_ADDR'}: 'unknown address'; |
36 | our $REMOTE_ADDR = (defined( $ENV{'REMOTE_ADDR'}) ) ? $ENV{'REMOTE_ADDR'}: 'unknown address'; |
| 13 | |
37 | |
| 14 | |
38 | |
| 15 | =head2 includePGtext |
39 | =head2 includePGtext |
| 16 | |
40 | |
| 17 | includePGtext($string_ref, $envir_ref) |
41 | includePGtext($string_ref, $envir_ref) |
| … | |
… | |
| 164 | =cut |
188 | =cut |
| 165 | |
189 | |
| 166 | ## converts full path names to to use the $dirDelim instead of / |
190 | ## converts full path names to to use the $dirDelim instead of / |
| 167 | |
191 | |
| 168 | sub convertPath { |
192 | sub convertPath { |
| 169 | &Global::convertPath; |
193 | return wantarray ? @_ : shift; |
| 170 | } |
194 | } |
| 171 | |
195 | |
| 172 | # hacks to make this program work independent of Global.pm |
196 | # hacks to make this program work independent of Global.pm |
| 173 | sub getDirDelim { |
197 | sub getDirDelim { |
| 174 | return ("/"); |
198 | return ("/"); |
| … | |
… | |
| 308 | warn("$0: createDirectory error", " Can't do chmod($permission, $dirName)"); |
332 | warn("$0: createDirectory error", " Can't do chmod($permission, $dirName)"); |
| 309 | unless ($numgid == -1) {chown(-1,$numgid,$dirName) or |
333 | unless ($numgid == -1) {chown(-1,$numgid,$dirName) or |
| 310 | warn("$0: createDirectory error", " Can't do chown(-1,$numgid,$dirName)");} |
334 | warn("$0: createDirectory error", " Can't do chown(-1,$numgid,$dirName)");} |
| 311 | } |
335 | } |
| 312 | |
336 | |
| 313 | |
337 | 1; |