Esempio n. 1
0
 /**
  * Adds the given file to the hash pool. The hash will be calculated over the total hash pool.
  * @param \System\IO\File The file to include in the hashing
  */
 public final function addFile(\System\IO\File $file)
 {
     if ($this->hash) {
         if ($file->exists()) {
             hash_update_file($this->hash, $file->getFullPath());
         } else {
             throw new \System\Error\Exception\FileNotFoundException('The given file does not exists: ' . $file->getFilename());
         }
     } else {
         throw new \System\Error\Exception\InvalidMethodException('This method is called after finalizing the hash');
     }
 }
Esempio n. 2
0
 /**
  * Adds an attachment to the Email message.
  * @param \System\IO\File The file object to attach
  */
 public final function addAttachment(\System\IO\File $file)
 {
     if ($file->exists()) {
         $this->attachments[] = $file;
     } else {
         throw new \System\Error\Exception\FileNotFoundException('The given email attachment file ' . $file->getFilename() . ' does not exists');
     }
 }
 /**
  * Transfer the file to its new location by copying it.
  * @param \System\IO\File The sourcefile.
  * @return bool True on success, false otherwise
  */
 public final function transferFile(\System\IO\File $file)
 {
     $target = \System\IO\Directory::getPath($this->targetFolder . $file->getFilename());
     return \System\IO\File::writeContents($target, $file->getContents()) instanceof \System\IO\File;
 }
Esempio n. 4
0
 /**
  * Gets the url name of the file. This will be in the following form:
  * if $file = 'abc.jpg', and container = 'myRandomContainer', then
  * retrun value is 'abc.myran.jpg'
  * @param File The file to use
  * @param string The container to use
  * @return string The name of the url file. This excludes base paths.
  */
 public static function getURLFile(\System\IO\File $file, $container)
 {
     $filename = $file->getFilename();
     $extension = $file->getExtension();
     $filename = mb_substr($filename, 0, -mb_strlen($extension));
     $containerNameUsage = self::getContainerNameParts($container);
     $filename .= $containerNameUsage . '.' . $file->getExtension();
     return $filename;
 }
Esempio n. 5
0
 /**
  * Transfer the file to its new location by copying it.
  * @param \System\IO\File The sourcefile.
  * @return bool True on success, false otherwise
  */
 public final function transferFile(\System\IO\File $file)
 {
     return $this->putBlocking($file->getFilename(), $file->getFullPath());
 }