public virtual Uri Write(Stream source, Uri sink) { if (sink == null) { throw new ArgumentException("Uri must not be null"); } if (IoMode.HasFlag(IO.IoMode.Write) && sink.IsFile) { var filename = IoUtils.UriToFileName(sink); var file = new FileStream(filename, FileMode.Create); var target = new BufferedStream(file); var bufferSize = 1024 * 1024; var buffer = new byte[bufferSize]; var oldPos = source.Position; int readByte = 0; int position = 0; long endpos = source.Length - 1; while (position < endpos) { readByte = source.Read(buffer, 0, bufferSize); target.Write(buffer, 0, readByte); position += readByte; } target.Flush(); target.Close(); source.Position = oldPos; } return(sink); }
// SetIoMode(nn::ssl::sf::IoMode) public ResultCode SetIoMode(ServiceCtx context) { IoMode ioMode = (IoMode)context.RequestData.ReadUInt32(); Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { ioMode }); return(ResultCode.Success); }
public ISslConnection(ulong processId, SslVersion sslVersion) { _processId = processId; _sslVersion = sslVersion; _ioMode = IoMode.Blocking; _sessionCacheMode = SessionCacheMode.None; _verifyOption = VerifyOption.PeerCa | VerifyOption.HostName; }
public virtual Stream Read(Uri uri) { var result = default(Stream); if (IoMode.HasFlag(IO.IoMode.Read) && uri.IsFile) { var filename = IoUtils.UriToFileName(uri); var file = new FileStream(filename, FileMode.Open); } return(result); }
internal static JobIo ForFile(Context c, string path, IoMode mode) { var cpath = GCHandle.Alloc(Encoding.ASCII.GetBytes(path + char.MinValue), GCHandleType.Pinned); try { return(new JobIo(c, NativeMethods.imageflow_io_create_for_file(c.Pointer, mode, cpath.AddrOfPinnedObject(), CleanupWith.Context))); } finally{ cpath.Free(); } }
// SetIoMode(nn::ssl::sf::IoMode) public ResultCode SetIoMode(ServiceCtx context) { if (_connection == null) { return(ResultCode.NoSocket); } _ioMode = (IoMode)context.RequestData.ReadUInt32(); _connection.Socket.Blocking = _ioMode == IoMode.Blocking; Logger.Stub?.PrintStub(LogClass.ServiceSsl, new { _ioMode }); return(ResultCode.Success); }
public byte[] ToBytes(IoMode ioMode) { unsafe { const int maxBufSize = 1024; Span <byte> res = stackalloc byte[maxBufSize]; ulong len; fixed(G2 *ptr = &this) fixed(byte *resPtr = res) { len = MclBls12381.Imports.MclBnG2GetStr.Value(resPtr, maxBufSize, ptr, (int)ioMode); } return(res.Slice(0, (int)len).ToArray()); } }
public byte[] ToBytes(IoMode ioMode) { unsafe { const int maxSize = 1024; Span <byte> buf = stackalloc byte[maxSize]; fixed(Fr *ptr = &this) fixed(byte *bufPtr = buf) { var size = MclBls12381.Imports.MclBnFrGetStr.Value(bufPtr, maxSize, ptr, (int)ioMode); if (size == 0 || size > 1024) { throw new InvalidOperationException("mclBnFr_getStr failed to serialize Fr"); } return(buf.Slice(0, (int)size).ToArray()); } } }
public virtual Content <Stream> Read(Uri source, Content <Stream> sink) { var result = default(Content <Stream>); if (IoMode.HasFlag(IO.IoMode.Read) && source.IsFile) { var filename = IoUtils.UriToFileName(source); var file = new FileStream(filename, FileMode.Open); result = Read(file, Detector.Use(file)); // test if there is a provider with file's extension: if (result == null) { var info = Detector.Find(Path.GetExtension(filename).Replace(".", "")); if (info.Magics == null || info.Magics.Length == 0) { result = Read(file, info); } } if (result != null) { if (result.Source == null) { result.Source = source.AbsoluteUri; } if (result.Description == null) { result.Description = source.Segments[source.Segments.Length - 1]; } } else { file.Close(); } } return(result); }
public static extern JobIoPointer imageflow_io_create_for_file(ContextPointer context, IoMode mode, [MarshalAs(UnmanagedType.LPStr)] string filename, CleanupWith cleanup);
public static extern IntPtr imageflow_io_create_for_file(IntPtr context, IoMode mode, IntPtr filename, CleanupWith cleanup);
public virtual IContentIo <TSource> FindMime(string mimeType, IoMode mode) { return(FirstOrDefault(_contentIos.Where(sinkIo => sinkIo.Detector.ContentSpecs.Any(s => s.MimeType == mimeType) && sinkIo.IoMode.HasFlag(mode)))); }
public virtual IContentIo <TSource> Find(TSource stream, IoMode mode) { return(FirstOrDefault(_contentIos.Where(sinkIo => sinkIo.Supports(stream) && sinkIo.IoMode.HasFlag(mode)))); }
public virtual IContentIo <TSource> Find(long streamType, IoMode mode) { return(FirstOrDefault(_contentIos.Where(sinkIo => sinkIo.Detector.Supports(streamType) && sinkIo.IoMode.HasFlag(mode)))); }
public virtual IContentIo <TSource> Find(string extension, IoMode mode) { return(FirstOrDefault(_contentIos.Where(sinkIo => sinkIo.Detector.Supports(extension) && sinkIo.IoMode.HasFlag(mode)))); }