public static FileBlockReader Open(string filePath, long length) { var result = new FileBlockReader(filePath, length); result.ReleaseFile(new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); return result; }
public FileBlockReader OpenReadCachedOnly(FSItem item) { var path = Path.Combine(cachePath, item.Id); if (!File.Exists(path)) { return(null); } CacheEntry entry; if (access.TryGetValue(item.Id, out entry)) { entry.AccessTime = DateTime.UtcNow; } Log.Trace("Opened cached: " + item.Id); return(FileBlockReader.Open(path, item.Length)); }