public function testLseekCurPositive()
 {
     $state = smbclient_state_new();
     smbclient_state_init($state, null, SMB_USER, SMB_PASS);
     $file = smbclient_creat($state, $this->testuri);
     smbclient_write($state, $file, 'abcdefgh');
     $ret = smbclient_lseek($state, $file, 3, SEEK_CUR);
     $this->assertEquals(11, $ret);
     smbclient_write($state, $file, 'foo', 3);
     smbclient_close($state, $file);
     $this->assertStringEqualsFile($this->realfile, sprintf('%s%c%c%c%s', 'abcdefgh', 0, 0, 0, 'foo'));
 }
 public function testWriteOversized()
 {
     $state = smbclient_state_new();
     smbclient_state_init($state, null, SMB_USER, SMB_PASS);
     $file = smbclient_creat($state, $this->testuri);
     $this->assertTrue(is_resource($file));
     // Write way more bytes than data:
     $ret = smbclient_write($state, $file, $this->testdata, 1000);
     $this->assertTrue(is_integer($ret));
     $this->assertEquals(strlen($this->testdata), $ret);
     // Use the regular filesystem to check the file that was created:
     $this->assertFileExists($this->realfile);
     $this->assertEquals(filesize($this->realfile), $ret);
     $this->assertStringEqualsFile($this->realfile, $this->testdata);
 }
Example #3
0
 /**
  * @param resource $file
  * @param string $data
  * @param int $length
  * @return int
  */
 public function write($file, $data, $length = null)
 {
     $result = @smbclient_write($this->state, $file, $data, $length);
     $this->testResult($result, $file);
     return $result;
 }