*/ //$childfile->close(); } $myfile = new ProdsFile($account, "/tempZone/home/rods/test1"); $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";
$pass = '******'; /** * This simple script reads JPEG/TIFF files stored in iRODS, extract * its EXIF information, and set it as userdefined metadata. * Note: EXIF php module is required for this program to work properly * http://us2.php.net/manual/en/ref.exif.php * * Example: php -f exif2meta.php /tempZone/home/rods/test2/RIMG0087.jpg */ //----------don't modify below this line!! ----------- require_once "../src/Prods.inc.php"; $target_file = $argv[1]; try { $account = new RODSAccount($host, $port, $user, $pass); $irodsfile = new ProdsFile($account, $target_file, true); $metas = $irodsfile->getMeta(); $metaalreadyset = false; foreach ($metas as $meta) { if ($meta->name == 'EXIF.ExifVersion') { $metaalreadyset = true; break; } } if ($metaalreadyset === true) { $time = '[' . date('c') . ']'; echo "{$time} 0: metadata already set for '{$target_file}'\n"; exit(0); } // download file from irods to tmp $localfile = '/tmp/' . basename($target_file); if (file_exists($localfile)) {
<?php require_once "/Path/to/Prods/src/Prods.inc.php"; // make an iRODS account object for connection, assuming: // username: demouser, password: demopass, server: srbbrick15.sdsc.edu, port: 1247 $account = new RODSAccount("srbbrick15.sdsc.edu", 1247, "demouser", "demopass"); //create an file object for read, assuming the path is "/tempZone/home/demouser/test_read.txt" $myfile = new ProdsFile($account, "/tempZone/home/demouser/test_read.txt"); //create an metadata entry and associate it with the file $meta = new RODSMeta("myname", "myvalue"); $myfile->addMeta($meta); //get all metadata of the file, and print them //the output should look like "Name: Myname | Value: myvalue" $metadatas = $myfile->getMeta(); foreach ($metadatas as $meta) { echo 'Name: ' . $meta->name . " | " . $meta->value . "\n"; }