/** * create a new protected file object which has properties that can be used for writing an actual file to * * @param string $name * @return ProtectedFile */ public static function createForWriting($name) { $file = new ProtectedFile(); $file->name = $name; $file->generateUID(); $path = $file->getFilePath(); if (!file_exists($path)) { if (!@mkdir($path, 0755, true)) { throw new Exception("{$path} could not be created: permission denied"); } } return $file; }