Example #1
0
        public void Execute(FileSystemCache cache)
        {
            var path      = cache.GetFilePath(Key);
            var finalPart = path.LastIndexOf('/');

            Directory.CreateDirectory((finalPart == -1)?path:path.Substring(0, finalPart));
            File.WriteAllBytes(path, Data);

            var entry = cache.GetEntry(Key);

            if (entry == null)
            {
                entry           = new FileSystemCacheEntry();
                entry.Key       = Key;
                entry.LastRead  = DateTime.MinValue;
                entry.LastWrite = DateTime.Now;
                entry.Length    = Data.Length;

                cache.AddEntry(entry);
            }
            else
            {
                entry.Length = Data.Length;
            }
        }
Example #2
0
        public int GetBytesRequired(FileSystemCache cache)
        {
            var existingFile = cache.GetEntry(Key);

            if (existingFile != null)
            {
                return(-((int)existingFile.Length));
            }
            return(0);
        }
Example #3
0
 public void Execute(FileSystemCache cache)
 {
     File.Delete(cache.GetFilePath(Key));
     cache.RemoveEntry(Key);
 }