Ejemplo n.º 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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 3
0
 public FileHandleEventArgs(FileHandle handle)
 {
     this.handle = handle;
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 8
0
 public void Update(FileHandle handle)
 {
     Remove(handle.Id);
     Insert(handle);
 }
Ejemplo n.º 9
0
 public void Insert(FileHandle handle)
 {
     handles.Add(handle);
 }