WeBWorK::PG::IO - Private functions used by WeBWorK::PG::Translator for file IO.

From WeBWorK

Jump to: navigation


SYNOPSIS

 BEGIN { $main::VERSION = "2.0" }
 use WeBWorK::PG::IO;
 my %functions_to_share = %WeBWorK::PG::IO::SHARE;

DESCRIPTION

This module defines several functions to be shared with a safe compartment by the PG translator. It also loads a version-specific module (if found) based on the value of the $main::VERSION variable.

This module also maintains a hash %WeBWorK::PG::IO::SHARE. The keys of this hash are the names of functions, and the values are the name of the package that contains the function.

FUNCTIONS

includePGtext($string_ref, $envir_ref)

This is used in processing some of the sample CAPA files and in creating aliases to redirect calls to duplicate problems so that they go to the original problem instead. It is called by includePGproblem.

It reads and evaluates the string in the same way that the Translator evaluates the string in a PG file.

read_whole_problem_file($filePath)

Don't use for huge files. The file name will have .pg appended to it if it doesn't already end in .pg. Files may become double spaced.? Check the join below. This is used in importing additional .pg files as is done in the sample problems translated from CAPA. Returns a reference to a string containing the contents of the file.

convertPath($path)

Currently a no-op. Returns $path unmodified.

fileFromPath($path)

Uses &getDirDelim to determine the path delimiter. Returns the last segment of the path (i.e. the text after the last delimiter).

directoryFromPath($path)

Uses &getDirDelim to determine the path delimiter. Returns the initial segments of the of the path (i.e. the text up to the last delimiter).

createFile($fileName, $permission, $numgid)

Creates a file with the given name, permission bits, and group ID.

createDirectory($dirName, $permission, $numgid)

Creates a directory with the given name, permission bits, and group ID.

path_is_course_subdir($path)

Checks to see if the given path is a sub directory of the courses directory