/**
  * Renames the current directory
  * 
  * This operation will NOT be performed until the filesystem transaction
  * has been committed, if a transaction is in progress. Any non-Flourish
  * code (PHP or system) will still see this directory (and all contained
  * files/dirs) as existing with the old paths until that point.
  * 
  * @param  string  $new_dirname  The new full path to the directory or a new name in the current parent directory
  * @param  boolean $overwrite    If the new dirname already exists, TRUE will cause the file to be overwritten, FALSE will cause the new filename to change
  * @return void
  */
 public function rename($new_dirname, $overwrite)
 {
     $this->tossIfDeleted();
     if (!$this->getParent()->isWritable()) {
         throw new fEnvironmentException('The directory, %s, can not be renamed because the directory containing it is not writable', $this->directory);
     }
     // If the dirname does not contain any folder traversal, rename the dir in the current parent directory
     if (preg_match('#^[^/\\\\]+$#D', $new_dirname)) {
         $new_dirname = $this->getParent()->getPath() . $new_dirname;
     }
     $info = fFilesystem::getPathInfo($new_dirname);
     if (!file_exists($info['dirname'])) {
         throw new fProgrammerException('The new directory name specified, %s, is inside of a directory that does not exist', $new_dirname);
     }
     if (file_exists($new_dirname)) {
         if (!is_writable($new_dirname)) {
             throw new fEnvironmentException('The new directory name specified, %s, already exists, but is not writable', $new_dirname);
         }
         if (!$overwrite) {
             $new_dirname = fFilesystem::makeUniqueName($new_dirname);
         }
     } else {
         $parent_dir = new fDirectory($info['dirname']);
         if (!$parent_dir->isWritable()) {
             throw new fEnvironmentException('The new directory name specified, %s, is inside of a directory that is not writable', $new_dirname);
         }
     }
     rename($this->directory, $new_dirname);
     // Make the dirname absolute
     $new_dirname = fDirectory::makeCanonical(realpath($new_dirname));
     // Allow filesystem transactions
     if (fFilesystem::isInsideTransaction()) {
         fFilesystem::rename($this->directory, $new_dirname);
     }
     fFilesystem::updateFilenameMapForDirectory($this->directory, $new_dirname);
 }