/** * Module containing the strategies to handle * the administration of the current directory */ module php/reflect/inclusion/currentdir strategies /** * Main strategy */ find-file-in-current-directory(|filename) = find-file-in-directory(add-current-dir | filename) /** * Adds the current directory in front of a path * if the path is relative. Otherwise it will build the * path. * * @type String -> String */ add-current-dir = ?path ; add-dir(get-php-current-directory | path ) /** * Resets the current directory and removes * all the old current directories */ php-clean-current-directory = <rm-config> "php-old-current-directory" ; <rm-config> "php-current-directory" /** * Sets the current directory for the process. * * @param path String, the path to the working directory */ set-php-current-directory(|path) = save-php-current-directory ; set-php-direcory(|"current", path) /** * Retrieves the current directory for the process. * The default value is the standard current working directory * * @type _ -> String */ get-php-current-directory = get-php-direcory(|"current") /** * Saves the current directory. The directory is saved in such * a way that one can return to the old current directory by * using 'prev-php-current-directory'. */ save-php-current-directory = ( <get-config> "php-old-current-directory" ; ![<get-php-current-directory> | <id> ] ; <set-config> ("php-old-current-directory",<id>) ) <+ //we did not yet get into another directory <set-config> ("php-old-current-directory",[ <get-php-current-directory> ]) /** * Resets the current directory to the directory before the * current directory. Should be used together with 'save-php-current-directory' * to taverse directories. */ prev-php-current-directory = <get-config> "php-old-current-directory" ; ?[head | tail] ; <set-config> ("php-current-directory",head) ; <set-config> ("php-old-current-directory",tail)