Skip to content
Snippets Groups Projects
Commit 80a2e974 authored by Demian Katz's avatar Demian Katz
Browse files

Create directory structure for config files automatically when saving.

parent 1e92ff48
No related merge requests found
......@@ -146,6 +146,20 @@ class Writer
*/
public function save()
{
// Create parent directory structure if necessary:
$stack = array();
$dirname = dirname($this->filename);
while (!empty($dirname) && !is_dir($dirname)) {
$stack[] = $dirname;
$dirname = dirname($dirname);
}
foreach (array_reverse($stack) as $dir) {
if (!mkdir($dir)) {
return false;
}
}
// Write the file:
return file_put_contents($this->filename, $this->getContent());
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment