diff options
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 38cb3a6..1b9777f 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1007,6 +1007,38 @@ namespace OpenSim.Framework | |||
1007 | } | 1007 | } |
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | /// <summary> | ||
1011 | /// Copy data from one stream to another, leaving the read position of both streams at the beginning. | ||
1012 | /// </summary> | ||
1013 | /// <param name='inputStream'> | ||
1014 | /// Input stream. Must be seekable. | ||
1015 | /// </param> | ||
1016 | /// <exception cref='ArgumentException'> | ||
1017 | /// Thrown if the input stream is not seekable. | ||
1018 | /// </exception> | ||
1019 | public static Stream Copy(Stream inputStream) | ||
1020 | { | ||
1021 | if (!inputStream.CanSeek) | ||
1022 | throw new ArgumentException("Util.Copy(Stream inputStream) must receive an inputStream that can seek"); | ||
1023 | |||
1024 | const int readSize = 256; | ||
1025 | byte[] buffer = new byte[readSize]; | ||
1026 | MemoryStream ms = new MemoryStream(); | ||
1027 | |||
1028 | int count = inputStream.Read(buffer, 0, readSize); | ||
1029 | |||
1030 | while (count > 0) | ||
1031 | { | ||
1032 | ms.Write(buffer, 0, count); | ||
1033 | count = inputStream.Read(buffer, 0, readSize); | ||
1034 | } | ||
1035 | |||
1036 | ms.Position = 0; | ||
1037 | inputStream.Position = 0; | ||
1038 | |||
1039 | return ms; | ||
1040 | } | ||
1041 | |||
1010 | public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) | 1042 | public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) |
1011 | { | 1043 | { |
1012 | return SendXmlRpcCommand(url, methodName, args); | 1044 | return SendXmlRpcCommand(url, methodName, args); |