public void RespondWithBytes (byte[] bytes, Coherent.UI.ResourceResponse response) { IntPtr buffer = response.GetBuffer((uint)bytes.Length); if (buffer == IntPtr.Zero) { response.SignalFailure(); return; } Marshal.Copy(bytes, 0, buffer, bytes.Length); response.SignalSuccess(); }
public void WriteFileToFilesystem (string cleanUrl, Coherent.UI.ResourceData resource) { #if COHERENT_UNITY_UNSUPPORTED_PLATFORM throw new ApplicationException("Coherent UI doesn't support the target platform!"); #else IntPtr buffer = resource.GetBuffer(); if (buffer == IntPtr.Zero) { resource.SignalFailure(); return; } byte[] bytes = new byte[resource.GetSize()]; Marshal.Copy(buffer, bytes, 0, bytes.Length); try { File.WriteAllBytes(cleanUrl, bytes); } catch (IOException ex) { Console.Error.WriteLine(ex.Message); resource.SignalFailure(); return; } resource.SignalSuccess(); #endif }
public void WriteFileToFilesystem (string cleanUrl, Coherent.UI.ResourceData resource) { IntPtr buffer = resource.GetBuffer(); if (buffer == IntPtr.Zero) { resource.SignalFailure(); return; } byte[] bytes = new byte[resource.GetSize()]; Marshal.Copy(buffer, bytes, 0, bytes.Length); try { File.WriteAllBytes(cleanUrl, bytes); } catch (IOException ex) { Console.Error.WriteLine(ex.Message); resource.SignalFailure(); return; } resource.SignalSuccess(); }