Ejemplo n.º 1
0
Archivo: Dir.php Proyecto: mbcraft/piol
 /**
  * 
  * Checks if this directory is a parent of the provided child.
  * 
  * @param \Mbcraft\Piol\File|\Mbcraft\Piol\Dir $child
  * @return boolean true if the parameter is a direct child of this directory, false otherwise.
  * 
  * @throws IOException if the child is not a valid File or Dir instance.
  * 
  * @api
  */
 public function isParentOf($child)
 {
     if (!$child instanceof __FileSystemElement) {
         throw new IOException("The provided element is not a valid \\Piol\\File or \\Piol\\Dir.");
     }
     $path_p = $this->getFullPath();
     $path_c = $child->getFullPath();
     //for windows dirs
     $parent_path_c = dirname($path_c) . DIRECTORY_SEPARATOR;
     $parent_path_c = str_replace("\\", DS, $parent_path_c);
     return $parent_path_c == $path_p;
 }
Ejemplo n.º 2
0
 function testCreateNewFile()
 {
     $f_new = new File("/test/test_dir/content_dir/new_file.txt");
     $this->assertNotEquals("", $f_new->getFullPath());
     $this->assertNotNull($f_new->getFullPath());
     //$current_mtime = $f_new->getModificationTime();
     $this->assertFalse($f_new->exists(), "Il file esiste!!");
     $f_new->touch();
     //$new_mtime = $f_new->getModificationTime();
     //$this->assertNotEqual($current_mtime, $new_mtime);
     $this->assertTrue($f_new->exists(), "Il file non è stato creato!");
     $f_new->delete();
     $this->assertFalse($f_new->exists(), "Il file esiste!!");
 }