Exemple #1
0
 /**
  * Default Constructor.
  *
  * @param RODSAccount account iRODS account used for connection
  * @param string $path_str the path of this dir
  * @param boolean $verify whether verify if the path exsits
  * @param RODSDirStats $stats if the stats for this dir is already known, initilize it here.
  * @return a new ProdsDir
  */
 public function __construct(RODSAccount &$account, $path_str, $verify = false, RODSDirStats $stats = NULL)
 {
     $this->position = 0;
     $this->stats = $stats;
     parent::__construct($account, $path_str);
     if ($verify === true) {
         if ($this->exists() === false) {
             throw new RODSException("Directory '{$this}' does not exist", 'PERR_PATH_DOES_NOT_EXISTS');
         }
     }
 }
Exemple #2
0
 /**
  * The class constructor
  */
 public function __construct(RODSAccount &$account, $path_str, $verify = false, RODSFileStats $stats = NULL)
 {
     $this->l1desc = -1;
     $this->stats = $stats;
     if ($path_str[strlen($path_str) - 1] == '/') {
         throw new RODSException("Invalid file name '{$path_str}' ", 'PERR_USER_INPUT_PATH_ERROR');
     }
     parent::__construct($account, $path_str);
     if ($verify === true) {
         if ($this->exists() === false) {
             throw new RODSException("File '{$this}' does not exist", 'PERR_PATH_DOES_NOT_EXISTS');
         }
     }
 }
    $myfile->open("w+", "demoResc");
    $bytes = $myfile->write("Hello world from Sifang!\n");
    echo "{$bytes} bytes written <br/>\n";
    $myfile->close();
    $myfile->open("r", "demoResc", true);
    $str = $myfile->read(200);
    echo "the file reads: <pre>{$str}</pre>";
    $myfile->close();
    $file_src = new ProdsFile($account, "/tempZone/home/rods/test.php");
    $file_dest = new ProdsFile($account, "/tempZone/home/rods/test.sifang.txt");
    //$file_src->cpMeta($file_dest);
    foreach ($file_dest->getMeta() as $meta) {
        echo "{$file_dest->path_str}: {$meta->name}; {$meta->value}; {$meta->units} <br/> \n";
    }
    $meta = array(new RODSMeta("test1", "1"));
    $files = ProdsPath::queryMeta($account, $meta);
    foreach ($files as $file) {
        echo "{$file} <br/>\n";
    }
    echo "<hr/>";
    $dirs = ProdsPath::queryMeta($account, $meta, 1);
    foreach ($dirs as $dir) {
        echo "{$dir} <br/>\n";
    }
    $file = new ProdsFile($account, "/tempZone/home/rods/test.php");
    var_dump($file->getStats());
    echo "<br/>--- connection successful! #2--- " . microtime() . " <br/>\n";
} catch (RODSException $e) {
    echo $e;
    echo $e->showStackTrace();
}
Exemple #4
0
function modMetadata($mod_batch, ProdsPath $target_path)
{
    foreach ($mod_batch as $mod_instrction) {
        $op_type = $mod_instrction['op'];
        switch ($op_type) {
            case 'add':
                $target_path->addMeta(new RODSMeta($mod_instrction['target']['name'], $mod_instrction['target']['value'], $mod_instrction['target']['unit']));
                break;
            case 'delbyid':
                $target_path->rmMetaByID($mod_instrction['id']);
                break;
            case 'updatebyid':
                $target_path->rmMetaByID($mod_instrction['target']['id']);
                $target_path->addMeta(new RODSMeta($mod_instrction['target']['name'], $mod_instrction['target']['value'], $mod_instrction['target']['unit']));
                break;
            default:
                $response = array('success' => false, 'errmsg' => "op type '{$op_type}' no supported");
                echo json_encode($response);
                exit(0);
        }
    }
}
 public function __construct(RODSAccount &$account, $path_str)
 {
     parent::__construct($account, $path_str);
 }