[system] / trunk / webwork / system / cgi / cgi-scripts / profBuildProblemSetPage.pl Repository:
ViewVC logotype

Diff of /trunk/webwork/system/cgi/cgi-scripts/profBuildProblemSetPage.pl

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

Revision 149 Revision 150
167 # @allFiles = grep !/^\./, readdir SETHEADDIR; 167 # @allFiles = grep !/^\./, readdir SETHEADDIR;
168 #closedir SETHEADDIR; 168 #closedir SETHEADDIR;
169 #my @setHeadFiles = grep /header.*\.pg$/i, @allFiles; #get all files containing 'header' that end in .pg 169 #my @setHeadFiles = grep /header.*\.pg$/i, @allFiles; #get all files containing 'header' that end in .pg
170 170
171 # i should fix this so that it doesn't use find! 171 # i should fix this so that it doesn't use find!
172 my @setHeadFiles = `find $templateDirectory -name '*Header*.pg'`; 172 #my @setHeadFiles = `find $templateDirectory`;
173 for (my $i = 0; $i < @setHeadFiles; $i++) { 173 #for (my $i = 0; $i < @setHeadFiles; $i++) {
174 $setHeadFiles[$i] =~ s/$templateDirectory//; 174 # $setHeadFiles[$i] =~ s/$templateDirectory//;
175 chomp $setHeadFiles[$i]; 175 # chomp $setHeadFiles[$i];
176 } 176 #}
177
178 my @setHeaderFiles = grep /header.*\.pg$/i, recursiveFindFiles($templateDirectory);
179 map s|$templateDirectory/?||, @setHeaderFiles;
177 @sortedNames = sort @setHeadFiles; 180 @sortedNames = sort @setHeaderFiles;
178 181
179 ## print list of files 182 ## print list of files
180 $fileName = ''; 183 $fileName = '';
181 184
182 ($ind,$label,$date,@stat) = ('', '', '', ()); 185 ($ind,$label,$date,@stat) = ('', '', '', ());
183 %labels = (); 186 %labels = ();
283 $out .= $cgi->p . "\nExpected cgi parameter $param does not exist or is empty"; 286 $out .= $cgi->p . "\nExpected cgi parameter $param does not exist or is empty";
284 } 287 }
285 } 288 }
286 $out; 289 $out;
287} 290}
291
292sub recursiveFindFiles
293{
294 my $dir = shift;
295 $dir .= '/' unless $dir =~ m|/$|;
296 opendir DIR, $dir;
297 my @items = readdir DIR;
298 closedir DIR;
299 my @result;
300 foreach (@items) {
301 /^\./ and next;
302 -f "$dir$_" and push @result, "$dir$_";
303 -d "$dir$_" and push @result, recursiveFindFiles("$dir$_");
304 }
305 return @result;
306}

Legend:
Removed from v.149  
changed lines
  Added in v.150

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9