protected override unsafe Errno OnReadHandle(string path, OpenedPathInfo info, byte[] buf, long offset, out int bytesRead) { Logger.WriteLineIf(LogLevel.Verbose, _fslog_props, string.Format( "OnReadHandle, path={0}, handle={1}, buflength={2}, offset={3}", path, info.Handle, buf.Length, offset)); var eventArgs = new ReadFileEventArgs(new VirtualRawPath(path), buf, offset, info.Handle); if (this.ReadingFile != null) { try { ReadingFile(this, eventArgs); } catch (Exception ex) { Logger.WriteLineIf(LogLevel.Error, _log_props, string.Format( "Exception thrown when handling ReadingFile event. Exception: {0}", ex)); throw; } } bytesRead = eventArgs.BytesRead; Logger.WriteLineIf(LogLevel.Verbose, _fslog_props, string.Format("::Read {0} bytes.", bytesRead)); // @TODO FIXME: Now always return 0 but should handle error cases. return(0); }
public override void HandleReadingFile(IFilesys sender, ReadFileEventArgs args) { // A read here should be preceded by a path status inquiry. OpenFileInfo ofi; VirtualFile vf; if (_filesysContext.TryGetOpenFileInfo(args.Handle, out ofi)) { vf = ofi.VirtualFile; } else { throw new InvalidOperationException(); } if (vf.OnDemand) { Logger.WriteLineIf(LogLevel.Verbose, _log_props, string.Format("Virtual file suggests on demand retrieval, requesting data...")); UriTemplateMatch match; var succ = TryMatchPath(BasicTemplateString, args.VritualRawPath.PathString, out match); if (succ) { var extraParams = new NameValueCollection(); extraParams.Add(BytesToReadParamName, Convert.ToString(args.Buffer.Length)); extraParams.Add(OffsetParamName, Convert.ToString(args.Offset)); var uri = BasicPathMatch2ReqUri(match, extraParams); byte[] data = _serverProxy.Get(uri); // Size of data should be less than or equal to size of args.Buffer using (var ms = new MemoryStream(args.Buffer)) { ms.Write(data, 0, data.Length); } args.BytesRead = data.Length; Logger.WriteLineIf(LogLevel.Verbose, _log_props, string.Format("Successfully read {0} bytes.", args.BytesRead)); } } else { args.BytesRead = _fileManager.Read(vf, args.Buffer, args.Offset); } }
protected unsafe override Errno OnReadHandle(string path, OpenedPathInfo info, byte[] buf, long offset, out int bytesRead) { Logger.WriteLineIf(LogLevel.Verbose, _fslog_props, string.Format( "OnReadHandle, path={0}, handle={1}, buflength={2}, offset={3}", path, info.Handle, buf.Length, offset)); var eventArgs = new ReadFileEventArgs(new VirtualRawPath(path), buf, offset, info.Handle); if (this.ReadingFile != null) { try { ReadingFile(this, eventArgs); } catch (Exception ex) { Logger.WriteLineIf(LogLevel.Error, _log_props, string.Format( "Exception thrown when handling ReadingFile event. Exception: {0}", ex)); throw; } } bytesRead = eventArgs.BytesRead; Logger.WriteLineIf(LogLevel.Verbose, _fslog_props, string.Format("::Read {0} bytes.", bytesRead)); // @TODO FIXME: Now always return 0 but should handle error cases. return 0; }
public void HandleReadingFile(IFilesys sender, ReadFileEventArgs args) { throw new NotImplementedException(); }
void FushareFilesys_ReadingFile(object sender, ReadFileEventArgs e) { GetEventHandler(sender as IFilesys, e).HandleReadingFile( sender as IFilesys, e); }
public abstract void HandleReadingFile(IFilesys sender, ReadFileEventArgs args);