/// <summary> /// Opens the handle. /// </summary> /// <param name="path">The path.</param> /// <param name="info">The info.</param> public override Errno OpenHandle(string path, OpenedPathInfo info) { Errno retVal; if (info.OpenAccess == OpenFlags.O_RDONLY) { String readPath = _pathFactory.CreateVirtualPath4Read(new VirtualRawPath(path)); retVal = base.OpenHandle(readPath, info); } else { // This is a write. // @TODO Write to an existing file is not supported by BitTorrent. // It has to be enforced somewhere. String writePath = _pathFactory.CreateVirtualPath4Write(new VirtualRawPath(path)); retVal = base.OpenHandle(writePath, info); } // Add to filesys context. VirtualPath vp = VirtualPath.CreateFromRawString(path); VirtualFile vf = _fileManager.ReadVirtualFile(vp); FileAccess fa = IOUtil.OpenFlags2FileAccess(info.OpenAccess); var openFileInfo = new OpenFileInfo(info.Handle, vp, vf, fa); _filesysContext.AddOpenFile(info.Handle, openFileInfo); return(retVal); }