global $pwd;
global $args;

if(count($args) != 3) {
   printf("usage: mv file1 file2\n");
}
else {
   if(file_exists($pwd . "/" . $args[2])) {
      unlink($args[2]);
   }
   $fin = fopen($pwd . "/" . $args[1], "rb");
   $fout = fopen($pwd . "/" . $args[2], "wb");
   if($fin != null && $fout != null) {
      $ch = fgetc($fin);
      while(!feof($fin)) {
         fwrite($fout, $ch, 1);
         $ch = fgetc($fin);
      }
      fflush($fout);
      fclose($fout);
      fclose($fin);
      unlink($args[1]);
   }
   else {
      print("error: unable to open files...\n");
   }
}
