コード例 #1
0
 /**
  * Stores the given file $oFile into the CWD of the instance.
  * If the timestamp is not 'NULL', the timestamp month and year
  * will be used to save the file into a subfolder.
  *
  * @param IF_File $oFile
  * @param long $timestamp
  * 
  * @return bool
  * 
  * @throws Exception
  */
 public function store($oFile, $timestamp = NULL)
 {
     // Is $oFile given?
     if (!empty($oFile)) {
         // Do the file exits?
         if ($oFile->exists()) {
             // The path where the file will be stored.
             $storePath = self::getStoreFolderPath(TRUE, $timestamp);
             // Copy source file to destination store path.
             $oDestFile = new IF_File($storePath . "/" . $oFile->getName());
             if ($oFile->copyTo($oDestFile)) {
                 return TRUE;
             } else {
                 throw new Exception("Can not copy file \"" . $oFile->getAbsolutePath() . "\" to \"" . $oDestFile->getAbsolutePath() . "\"");
             }
         } else {
             throw new Exception("The file " . $oFile->getAbsolutePath() . " does not exist.");
         }
     } else {
         throw new Exception("Parameter 1 must be from type IF_File", 1);
     }
 }