Exemple #1
0
 public function testWriteFileText()
 {
     $tmpfile = tmpdir();
     writeFileText($tmpfile, 'UTF-8', "This is some text.\nYep, it sure is.\n");
     $this->assertEquals("This is some text.\nYep, it sure is.\n", file_get_contents($tmpfile));
 }
 /**
  * This writes the data to the manifest file.
  *
  * @param string $fileName This is the file name to write to. It defaults 
  * to the current value of the $fileName property. If given, it will set 
  * the value of the property also.
  *
  * @return void
  */
 public function write($fileName = null)
 {
     $this->_resetFileName($fileName);
     ksort($this->data);
     $output = array();
     foreach ($this->data as $path => $hash) {
         array_push($output, "{$hash} {$path}\n");
     }
     writeFileText($this->fileName, $this->fileEncoding, implode('', $output));
 }
Exemple #3
0
 /**
  * This writes the bag-info.txt file with the contents of bagInfoData.
  *
  * @return void
  * @author Eric Rochester <*****@*****.**>
  **/
 private function _writeBagInfo()
 {
     $lines = array();
     if (count($this->bagInfoData)) {
         foreach ($this->bagInfoData as $label => $value) {
             array_push($lines, "{$label}: {$value}\n");
         }
     }
     writeFileText($this->bagInfoFile, $this->tagFileEncoding, join('', $lines));
 }
Exemple #4
0
 /**
  * This writes the data to the fetch file.
  *
  * @return void
  */
 public function write()
 {
     $lines = array();
     foreach ($this->data as $fetch) {
         $data = array($fetch['url'], $fetch['length'], $fetch['filename']);
         array_push($lines, join(' ', $data) . "\n");
     }
     if (count($lines) == 0) {
         if (file_exists($this->fileName)) {
             unlink($this->fileName);
         }
     } else {
         writeFileText($this->fileName, $this->fileEncoding, join('', $lines));
     }
 }
Exemple #5
0
 /**
  * This writes the bag-info.txt file with the contents of bagInfoData.
  *
  * @return void
  * @author Eric Rochester <*****@*****.**>
  **/
 private function _writeBagInfo()
 {
     $lines = array();
     if (count($this->bagInfoData)) {
         foreach ($this->bagInfoData as $label => $value) {
             if (is_array($value)) {
                 foreach ($value as $v) {
                     $lines[] = "{$label}: {$v}\n";
                 }
             } else {
                 $lines[] = "{$label}: {$value}\n";
             }
         }
     }
     writeFileText($this->bagInfoFile, $this->tagFileEncoding, join('', $lines));
 }
 /**
  * This writes the data to the fetch file.
  *
  * @return void
  */
 public function write()
 {
     $lines = array();
     foreach ($this->data as $fetch) {
         $data = array($fetch['url'], $fetch['length'], $fetch['filename']);
         array_push($lines, join(' ', $data) . "\n");
     }
     writeFileText($this->fileName, $this->fileEncoding, join('', $lines));
 }