1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Squeeze a few more bytes out of put_file script.

This commit is contained in:
Chris Church 2014-06-19 16:19:23 -05:00
parent 8816ebb3f8
commit 8a121fd6ae

View file

@ -158,11 +158,11 @@ class Connection(object):
in_size = os.path.getsize(in_path) in_size = os.path.getsize(in_path)
script_template = ''' script_template = '''
$s = [System.IO.File]::OpenWrite("%s"); $s = [System.IO.File]::OpenWrite("%s");
$s.Seek(%d, [System.IO.SeekOrigin]::Begin) | Out-Null; [void]$s.Seek(%d, [System.IO.SeekOrigin]::Begin);
$b = [System.Convert]::FromBase64String("%s"); $b = [System.Convert]::FromBase64String("%s");
$s.Write($b, 0, $b.length) | Out-Null; [void]$s.Write($b, 0, $b.length);
$s.SetLength(%d) | Out-Null; [void]$s.SetLength(%d);
$s.Close() | Out-Null; [void]$s.Close();
''' '''
# Determine max size of data we can pass per command. # Determine max size of data we can pass per command.
script = script_template % (powershell._escape(out_path), in_size, '', in_size) script = script_template % (powershell._escape(out_path), in_size, '', in_size)