aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2014-11-18 14:49:45 +0100
committerHans Nilsson <[email protected]>2014-11-18 14:49:45 +0100
commit2feb7638d47f2d1012871de3040fa7d50f058e3a (patch)
tree16cb88e6b0a432b7a574d713e325b81a5a91b05d /lib/ssh/src
parent9366932892711cc4cce7a54b1e098e6d5c3db468 (diff)
parent0c6532f8068d0f748fefd3dd0fb41907f1255844 (diff)
downloadotp-2feb7638d47f2d1012871de3040fa7d50f058e3a.tar.gz
otp-2feb7638d47f2d1012871de3040fa7d50f058e3a.tar.bz2
otp-2feb7638d47f2d1012871de3040fa7d50f058e3a.zip
Merge branch 'hans/ssh/erl_tar_sftp/OTP-12180' into maint
* hans/ssh/erl_tar_sftp/OTP-12180: ssh: update vsn.mk ssh: Add ssh_sftp:open_tar/3,4 which opens a tar file at the server side of a channel. erl_tar: Extend api to define own storage media access functions.
Diffstat (limited to 'lib/ssh/src')
-rw-r--r--lib/ssh/src/ssh_sftp.erl26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/ssh/src/ssh_sftp.erl b/lib/ssh/src/ssh_sftp.erl
index 12479e9121..3b80f5326c 100644
--- a/lib/ssh/src/ssh_sftp.erl
+++ b/lib/ssh/src/ssh_sftp.erl
@@ -33,8 +33,8 @@
-export([start_channel/1, start_channel/2, start_channel/3, stop_channel/1]).
--export([open/3, opendir/2, close/2, readdir/2, pread/4, read/3,
- open/4, opendir/3, close/3, readdir/3, pread/5, read/4,
+-export([open/3, open_tar/3, opendir/2, close/2, readdir/2, pread/4, read/3,
+ open/4, open_tar/4, opendir/3, close/3, readdir/3, pread/5, read/4,
apread/4, aread/3, pwrite/4, write/3, apwrite/4, awrite/3,
pwrite/5, write/4,
position/3, real_path/2, read_file_info/2, get_file_info/2,
@@ -162,6 +162,28 @@ open(Pid, File, Mode) ->
open(Pid, File, Mode, FileOpTimeout) ->
call(Pid, {open, false, File, Mode}, FileOpTimeout).
+open_tar(Pid, File, Mode) ->
+ open_tar(Pid, File, Mode, ?FILEOP_TIMEOUT).
+open_tar(Pid, File, Mode=[write], FileOpTimeout) ->
+ {ok,R} = open(Pid, File, Mode, FileOpTimeout),
+ erl_tar:init({Pid,R,FileOpTimeout}, write,
+ fun(write, {{P,H,T},Data}) ->
+ Bin = if is_list(Data) -> list_to_binary(Data);
+ is_binary(Data) -> Data
+ end,
+ {ok,{_Window,Packet}} = send_window(P, T),
+ write_file_loop(P, H, 0, Bin, size(Bin), Packet, T);
+ (position, {{P,H,T},Pos}) ->
+ position(P, H, Pos, T);
+ (close, {P,H,T}) ->
+ close(P, H, T)
+ end);
+open_tar(_Pid, _File, Mode, _FileOpTimeout) ->
+ {error,{illegal_mode,Mode}}.
+
+
+
+
opendir(Pid, Path) ->
opendir(Pid, Path, ?FILEOP_TIMEOUT).
opendir(Pid, Path, FileOpTimeout) ->