Esempio n. 1
0
 /**
  *
  * @param FTPFile $baseFile A file of the same server/connection
  * @param string $linkName The name of the link ("myLink -> /my/path/to/target")
  * @return array(0 => link_name, 1 => full_path_of_target)
  */
 protected static function parseLinkName(FTPFile $baseFile, $linkName)
 {
     if (preg_match('/^(.+) -> (.+)$/', $linkName, $matches)) {
         $urlParts = $baseFile->getURLComponents();
         $urlParts['path'] = $matches[2];
         return array($matches[1], AdvancedPathLib::buildURL($urlParts, AdvancedPathLib::OS_UNIX));
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Removes file
  *
  * @throws FileSystemException if removing of file fails
  * @return TRUE if file has successfully been removed
  */
 public function delete()
 {
     // use PHP
     if ($this->accessMode == self::PHP_ACCESS || $this->accessMode == self::UNKNOWN_ACCESS) {
         try {
             $objFilePhp = new FileSystemFile($this->file);
             $objFilePhp->delete();
             clearstatcache();
             if (!file_exists($objFilePhp->getAbsoluteFilePath())) {
                 return true;
             }
         } catch (FileSystemFileException $e) {
             \DBG::msg('FileSystemFile: ' . $e->getMessage());
         }
     }
     // use FTP
     if ($this->accessMode == self::FTP_ACCESS || $this->accessMode == self::UNKNOWN_ACCESS) {
         try {
             $objFileFtp = new FTPFile($this->file);
             $objFileFtp->delete();
             clearstatcache();
             if (!file_exists($objFileFtp->getAbsoluteFilePath())) {
                 return true;
             }
         } catch (FTPFileException $e) {
             \DBG::msg('FTPFile: ' . $e->getMessage());
         }
     }
     throw new FileSystemException('File: Unable to delete file ' . $this->file . '!');
 }
Esempio n. 3
0
 /**
  * Removes file
  *
  * @throws FileSystemException if removing of file fails
  * @return TRUE if file has successfully been removed
  */
 public function delete()
 {
     // use PHP
     if ($this->accessMode == self::PHP_ACCESS || $this->accessMode == self::UNKNOWN_ACCESS) {
         try {
             $fsFile = new FileSystemFile($this->file);
             $fsFile->delete();
         } catch (FileSystemFileException $e) {
             \DBG::msg('FileSystemFile: ' . $e->getMessage());
         }
     }
     // use FTP
     if ($this->accessMode == self::FTP_ACCESS || $this->accessMode == self::UNKNOWN_ACCESS) {
         try {
             $ftpFile = new FTPFile($this->file);
             $ftpFile->delete();
         } catch (FTPFileException $e) {
             \DBG::msg('FTPFile: ' . $e->getMessage());
         }
     }
     clearstatcache();
     if (file_exists($this->file)) {
         throw new FileSystemException('File: Unable to delete file ' . $this->file . '!');
     }
     return true;
 }
Esempio n. 4
0
 /**
  * @return bool TRUE if the file has been successfully renamed, FALSE otherwise
  */
 public function renameTo($newName)
 {
     $this->checkConnectPermission();
     return parent::renameTo($newName);
 }