/**
  * Prepare file for writing, including creating its parent directories and ancestors (freak, they're ancients I guess)
  *
  * @param string $path_to_file      Path to file
  * @param boolean $create           [optional] If the file should also be created
  * @param int $chmod                [optional] CHMOD permission to be applied
  * @return \IO\File
  */
 public static function Prepare($path_to_file, $create = false, $chmod = null)
 {
     $file = new File($path_to_file);
     $dirpath = $file->getPathInfo()->getDirname();
     //        if ($file->getName() == "sample2.txt")
     //            dd($dirpath);
     $directory = new \IO\Directory($dirpath);
     if (!$directory->exists()) {
         $directory->createRecursively();
     }
     // reinstantiate, and return
     $file = new File(localpath($directory->getPath(), $file->getName()), $create, $chmod);
     return $file;
 }