Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Manual merge of #1292 (put encoding call directly inside win-dedicate…
Browse files Browse the repository at this point in the history
…d function.
  • Loading branch information
cdujeu committed Nov 21, 2016
1 parent f49aa90 commit 72bf939
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions core/src/plugins/access.smb/smb.php
Expand Up @@ -22,6 +22,7 @@
###################################################################
namespace Pydio\Access\Driver\StreamProvider\SMB;

use Pydio\Core\Utils\TextEncoder;
use Pydio\Log\Core\Logger;

define ('SMB4PHP_VERSION', '0.8');
Expand Down Expand Up @@ -553,7 +554,7 @@ class smb_stream_wrapper extends smb
{
# variables

public $stream, $url, $parsed_url = array (), $mode, $tmpfile;
public $stream, $url, $parsed_url = array (), $mode, $tmpfile, $defer_stream_read;
public $need_flush = FALSE;
public $dir = array (), $dir_index = -1;

Expand Down Expand Up @@ -648,7 +649,6 @@ public function stream_open ($url, $mode, $options, $opened_path)
$url = smb::cleanUrl($url);
$this->url = $url;
$this->mode = $mode;
$this->defer_stream_read;
$this->parsed_url = $pu = smb::parse_url($url);
if ($pu['type'] <> 'path') trigger_error('stream_open(): error in URL', E_USER_ERROR);
switch ($mode) {
Expand Down Expand Up @@ -745,38 +745,36 @@ function ConvSmbParameterToWinOs($params)
{

$paramstemp = explode(" ", $params);

// first command '-d' or '-L' ?
if ($paramstemp[0] == "-d") {
$count_params = count($paramstemp);

// first command '-d' or '-L' ?
if ($paramstemp[0] === '-d') {

$count_params = count($paramstemp);
// index command = 4;
// index start path = 6;
$paramstemp[6] = '""'.$paramstemp[6];
$type_cmd = substr($paramstemp[4], 1);
switch ($type_cmd) {

case get:
case put:
case rename:
$index_end_path = $count_params - 2;
$paramstemp[$index_end_path] = $paramstemp[$index_end_path].'""';
$new_params = implode(" ", $paramstemp);
$new_params = str_replace(' ', '"" ""', $new_params);
break;

//Cmd: dir, del, rmdir, mkdir
default:
$index_end_path = $count_params - 2;
$paramstemp[$index_end_path] = $paramstemp[$index_end_path].'""';
$new_params = implode(" ", $paramstemp);
}
case 'get':
case 'put':
case 'rename':
$index_end_path = $count_params - 2;
$paramstemp[$index_end_path] = $paramstemp[$index_end_path].'""';
$new_params = implode(" ", $paramstemp);
$new_params = str_replace(' ', '"" ""', $new_params);
break;

return $new_params;
}
else {
return $params;
//Cmd: dir, del, rmdir, mkdir
default:
$index_end_path = $count_params - 2;
$paramstemp[$index_end_path] = $paramstemp[$index_end_path].'""';
$new_params = implode(" ", $paramstemp);
}
$params = $new_params;
}

return TextEncoder::toStorageEncoding($params);
}

###################################################################
Expand Down

0 comments on commit 72bf939

Please sign in to comment.