[system] / trunk / pg / lib / PGcore.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/PGcore.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 6256 Revision 6278
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: pg/lib/PGcore.pm,v 1.2 2010/05/14 12:31:19 gage Exp $ 4# $CVSHeader: pg/lib/PGcore.pm,v 1.5 2010/05/25 22:22:27 gage Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
15################################################################################ 15################################################################################
16package PGcore; 16package PGcore;
17 17
18use strict; 18use strict;
19BEGIN { 19BEGIN {
20 use Exporter; 20 use Exporter 'import';
21 our @EXPORT_OK = qw( not_null); 21 our @EXPORT_OK = qw(not_null);
22} 22}
23our $internal_debug_messages = []; 23our $internal_debug_messages = [];
24
24 25
25use PGanswergroup; 26use PGanswergroup;
26use PGresponsegroup; 27use PGresponsegroup;
27use PGrandom; 28use PGrandom;
28use PGalias; 29use PGalias;
29use PGloadfiles; 30use PGloadfiles;
30use WeBWorK::PG::IO; 31use WeBWorK::PG::IO(); # don't important any command directly
31use Tie::IxHash; 32use Tie::IxHash;
32 33
33################################## 34##################################
34# Utility macro 35# Utility macro
35################################## 36##################################
666 667
667 my $self = shift; 668 my $self = shift;
668 my $path = shift; 669 my $path = shift;
669 my $delim = "/"; 670 my $delim = "/";
670 my $tmpDirectory = $self->tempDirectory(); 671 my $tmpDirectory = $self->tempDirectory();
672#warn "\nTMP tmpDirectory $tmpDirectory";
671 unless ( -e $tmpDirectory) { # if by some unlucky chance the tmpDirectory hasn't been created, create it. 673 unless ( -e $tmpDirectory) { # if by some unlucky chance the tmpDirectory hasn't been created, create it.
672 my $parentDirectory = $tmpDirectory; 674 my $parentDirectory = $tmpDirectory;
673 $parentDirectory =~s|/$||; # remove a trailing / 675 $parentDirectory =~s|/$||; # remove a trailing /
674 $parentDirectory =~s|/\w*$||; # remove last node 676 $parentDirectory =~s|/\w*$||; # remove last node
675 my ($perms, $groupID) = (stat $parentDirectory)[2,5]; 677 my ($perms, $groupID) = (stat $parentDirectory)[2,5];
678 #FIXME where is the parentDirectory defined??
679#warn "Creating tmp directory at $tmpDirectory, perms $perms groupID $groupID";
676 createDirectory($tmpDirectory, $perms, $groupID) 680 $self->createDirectory($tmpDirectory, $perms, $groupID)
677 or warn "Failed to create directory at $path"; 681 or warn "Failed to create parent tmp directory at $path";
678 682
679 } 683 }
680 # use the permissions/group on the temp directory itself as a template 684 # use the permissions/group on the temp directory itself as a template
681 my ($perms, $groupID) = (stat $tmpDirectory)[2,5]; 685 my ($perms, $groupID) = (stat $tmpDirectory)[2,5];
682 #warn "&urePathToTmpFile: perms=$perms groupID=$groupID\n"; 686#warn "&urePathToTmpFile: directory=$tmpDirectory, perms=$perms, groupID=$groupID\n";
683 687
684 # if the path starts with $tmpDirectory (which is permitted but optional) remove this initial segment 688 # if the path starts with $tmpDirectory (which is permitted but optional) remove this initial segment
685 $path =~ s|^$tmpDirectory|| if $path =~ m|^$tmpDirectory|; 689 $path =~ s|^$tmpDirectory|| if $path =~ m|^$tmpDirectory|;
686 #$path = convertPath($path); 690 #$path = $self->convertPath($path);
687 691
688 # find the nodes on the given path 692 # find the nodes on the given path
689 my @nodes = split("$delim",$path); 693 my @nodes = split("$delim",$path);
690 694
691 # create new path 695 # create new path
692 $path = $tmpDirectory; #convertPath("$tmpDirectory"); 696 $path = $tmpDirectory; #convertPath("$tmpDirectory");
693 697
694 while (@nodes>1) { 698 while (@nodes>1) {
695 $path = $path . shift (@nodes) . "/"; #convertPath($path . shift (@nodes) . "/"); 699 $path = $path . shift (@nodes) . "/"; #convertPath($path . shift (@nodes) . "/");
700#warn "\PATH is now $path";
696 unless (-e $path) { 701 unless (-e $path) {
697 #system("mkdir $path"); 702 #system("mkdir $path");
698 #createDirectory($path,$Global::tmp_directory_permission, $Global::numericalGroupID) 703 #createDirectory($path,$Global::tmp_directory_permission, $Global::numericalGroupID)
704#warn "PATH $path perms $perms groupID $groupID";
699 createDirectory($path, $perms, $groupID) 705 $self->createDirectory($path, $perms, $groupID)
700 or warn "Failed to create directory at $path"; 706 or warn "Failed to create directory at $path with permissions $perms and groupID $groupID";
701 } 707 }
702 708
703 } 709 }
704 710
705 $path = $path . shift(@nodes); #convertPath($path . shift(@nodes)); 711 $path = $path . shift(@nodes); #convertPath($path . shift(@nodes));

Legend:
Removed from v.6256  
changed lines
  Added in v.6278

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9