/**
  * Set path to file for download
  *
  * The Last-Modified header will be set to files filemtime(), actually.
  * Returns PEAR_Error (HTTP_DOWNLOAD_E_INVALID_FILE) if file doesn't exist.
  * Sends HTTP 404 status if $send_404 is set to true.
  * 
  * @access  public
  * @return  mixed   Returns true on success or PEAR_Error on failure.
  * @param   string  $file       path to file for download
  * @param   bool    $send_404   whether to send HTTP/404 if
  *                              the file wasn't found
  */
 function setFile($file, $send_404 = true)
 {
     $file = realpath($file);
     if (!Codendi_File::isFile($file)) {
         if ($send_404) {
             $this->HTTP->sendStatusCode(404);
         }
         return PEAR::raiseError("File '{$file}' not found.", HTTP_DOWNLOAD_E_INVALID_FILE);
     }
     $this->setLastModified(filemtime($file));
     $this->file = PHP_BigFile::stream($file);
     $this->size = Codendi_File::getSize($file);
     return true;
 }
Esempio n. 2
0
 function test_our_hacks()
 {
     $big_file = $this->big_file;
     if (is_link($this->big_file)) {
         $big_file = readlink($this->big_file);
     }
     $this->assertTrue(Codendi_File::isFile($this->small_file));
     $this->assertEqual(Codendi_File::getSize($this->small_file), 14);
     if ($this->test_big_files) {
         $this->assertTrue(Codendi_File::isFile($big_file));
         $this->assertTrue(Codendi_File::getSize($big_file) > 4000000000);
         $this->assertNoErrors();
     }
 }