<?php
require_once 'System/Folders/Cached.php';
$sf = new System_Folders_Cached();
//show the path of the config file
echo 'Config file: ' . $sf->getDefaultConfigFile() . "\r\n";
//load the stored settings from last time
$err = $sf->loadFromFile();
echo 'Home: ' . $sf->getHome() . "\r\n";
echo 'Documents: ' . $sf->getDocuments() . "\r\n";
echo "\r\n";
$doc = $sf->getDocuments();
if (file_exists($doc)) {
echo "Setting new Documents directory\r\n";
//Set an own documents directory
// and save the settings for next time
$sf->setDocuments('/strange/path/to/MyDocuments/');
$sf->saveToFile();
echo 'New Documents directory: ' . $sf->getDocuments() . "\r\n";
echo "Run this program again to reset the path to default\r\n";
} else {
//unset the path
echo "Unsetting the documents directory\r\n";
$sf->setDocuments(null);
$sf->saveToFile();
echo 'New Documents directory: ' . $sf->getDocuments() . "\r\n";
}
?>
This example displays the location of the config file (in which
the folder settings are stored), shows some folder locations and
sets the documents directory to a (probably non-existing) directory
and saves the folder locations.
In the next program call, the documents directory is reset to the
normal one and saved again.