示例#1
0
        public FileHandle Duplicate(Guid id)
        {
            var handle = handleStore.Get(id);
            var duplicate = new FileHandle(Guid.NewGuid(), handle.Path);

            handleStore.Insert(duplicate);

            return duplicate;
        }
示例#2
0
        public FileHandle Insert(Stream stream, string filename)
        {
            var handle = new FileHandle(Guid.NewGuid(), Locate(filename));
            using (var filestream = File.Create(handle.Path))
            {
                stream.CopyTo(filestream);
            }

            handleStore.Insert(handle);
            if (totalSize != null)
            {
                totalSize += handle.Size;
            }

            return handle;
        }
示例#3
0
 public FileHandleEventArgs(FileHandle handle)
 {
     this.handle = handle;
 }
示例#4
0
        private static void Write(string action, FileHandle handle)
        {
            Console.Write(action + " [id=");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write(handle.Id);
            Console.ResetColor();
            Console.Write("|path=");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Write(handle.Path);
            Console.ResetColor();
            Console.Write("]");

            Console.WriteLine();
        }
示例#5
0
        public FileHandle Insert(string path)
        {
            var handle = new FileHandle(Guid.NewGuid(), Locate(path));
            File.Copy(path, handle.Path);

            handleStore.Insert(handle);
            if (totalSize != null)
            {
                totalSize += handle.Size;
            }

            return handle;
        }
示例#6
0
        public FileHandle Replace(Guid id, string path)
        {
            var replacement = new FileHandle(id, Locate(path));
            File.Copy(path, replacement.Path);

            handleStore.Update(replacement);
            if (totalSize != null)
            {
                totalSize += replacement.Size;
            }

            return replacement;
        }
示例#7
0
        public FileHandle Replace(Guid id, Stream stream, string filename)
        {
            var replacement = new FileHandle(id, Locate(filename));
            using (var filestream = File.Create(replacement.Path))
            {
                stream.CopyTo(filestream);
            }

            handleStore.Update(replacement);
            if (totalSize != null)
            {
                totalSize += replacement.Size;
            }

            return replacement;
        }
示例#8
0
 public void Update(FileHandle handle)
 {
     Remove(handle.Id);
     Insert(handle);
 }
示例#9
0
 public void Insert(FileHandle handle)
 {
     handles.Add(handle);
 }