Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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));
        }