Example #1
0
 /**
  * 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 self();
     $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;
 }