Ejemplo n.º 1
0
        //---------------------------------------------------------------------
        public override void Update(Commands.UpdateItemCommand Command)
        {
            if (this._ShellAdapter.Root.Length == 0)
            {
                throw new Exceptions.InvalidOperationException("Update", "FileSystem root is undefined");
            }
            string syspath = this.MakeSystemPathname(this._ShellAdapter.Root, Command.in_Pathname);

            string ShellCommand = "";

            if (Command.in_Item.Pathname.Equals(Command.in_Pathname))
            {
                ShellCommand = "touch " + syspath;
            }
            else
            {
                Pathname new_syspath = this.MakeSystemPathname(this._ShellAdapter.Root, Command.in_Item.Pathname);
                new_syspath.Separator = "/";
                ShellCommand          = "mv " + syspath + " " + new_syspath;
                ;
            }
            string output = this._ShellAdapter.ExecuteCommand(ShellCommand);

            Commands.ReadItemCommand ReadCmd = new Commands.ReadItemCommand();
            ReadCmd.in_Pathname = Command.in_Item.Pathname;
            this.Read(ReadCmd);
            if (ReadCmd.out_Item == null)
            {
                throw new Exceptions.InvalidOperationException("Update", "Item does not exist.");
            }

            // Return, OK.
            Command.out_Item = ReadCmd.out_Item;
            return;
        }
Ejemplo n.º 2
0
 //---------------------------------------------------------------------
 public void Invoke(CommandContext Command)
 {
     if (Command == null)
     {
     }
     else if (Command is Commands.SettingsCommand)
     {
         Commands.SettingsCommand SettingsCommand = (Commands.SettingsCommand)Command;
         this.Settings(SettingsCommand);
     }
     else if (Command is Commands.ListEntriesCommand)
     {
         Commands.ListEntriesCommand ListCommand = (Commands.ListEntriesCommand)Command;
         this.List(ListCommand);
     }
     else if (Command is Commands.CreateItemCommand)
     {
         Commands.CreateItemCommand CreateCommand = (Commands.CreateItemCommand)Command;
         this.Create(CreateCommand);
     }
     else if (Command is Commands.ReadItemCommand)
     {
         Commands.ReadItemCommand ReadCommand = (Commands.ReadItemCommand)Command;
         this.Read(ReadCommand);
     }
     else if (Command is Commands.UpdateItemCommand)
     {
         Commands.UpdateItemCommand UpdateCommand = (Commands.UpdateItemCommand)Command;
         this.Update(UpdateCommand);
     }
     else if (Command is Commands.DeleteItemCommand)
     {
         Commands.DeleteItemCommand DeleteCommand = (Commands.DeleteItemCommand)Command;
         this.Delete(DeleteCommand);
     }
     else if (Command is Commands.ReadFileContentCommand)
     {
         Commands.ReadFileContentCommand ReadContentCommand = (Commands.ReadFileContentCommand)Command;
         this.ReadFileContent(ReadContentCommand);
     }
     else if (Command is Commands.WriteFileContentCommand)
     {
         Commands.WriteFileContentCommand WriteContentCommand = (Commands.WriteFileContentCommand)Command;
         this.WriteFileContent(WriteContentCommand);
     }
     else
     {
     }
     return;
 }
Ejemplo n.º 3
0
 public abstract void Update(Commands.UpdateItemCommand Command);
Ejemplo n.º 4
0
 //---------------------------------------------------------------------
 public FileSystemItem Update(string Path, bool IsFolder, FileSystemItem Item)
 {
     Commands.UpdateItemCommand UpdateCommand = new Commands.UpdateItemCommand(Path, IsFolder, Item);
     this.Update(UpdateCommand);
     return(UpdateCommand.out_Item);
 }
        //---------------------------------------------------------------------
        public override void Update(Commands.UpdateItemCommand Command)
        {
            if (this._Root.Length == 0)
            {
                throw new Exceptions.InvalidOperationException("Update", "FileSystem root is undefined");
            }
            Pathname ItemPathname     = Pathname.Append(this._Root, Command.in_Pathname);
            Pathname DestItemPathname = Pathname.Append(this._Root, Command.in_Item.Pathname);
            bool     needs_move       = !ItemPathname.Equals(DestItemPathname);
            //bool needs_move = !ItemPathname.Path.Equals( DestItemPathname.Path, StringComparison.InvariantCultureIgnoreCase );
            FileSystemItem item = this.ItemFromPathname(ItemPathname);

            if (item.Exists)
            {
                if (item.IsFolder)
                {
                    if (needs_move)
                    {
                        Directory.Move(ItemPathname, DestItemPathname);
                    }
                    if (Command.in_Item.DateCreated.HasValue)
                    {
                        Directory.SetCreationTimeUtc(DestItemPathname, (DateTime)Command.in_Item.DateCreated);
                    }
                    else
                    {
                        Directory.SetCreationTimeUtc(DestItemPathname, (DateTime)item.DateCreated);
                    }
                    if (Command.in_Item.DateLastWrite.HasValue)
                    {
                        Directory.SetLastWriteTimeUtc(DestItemPathname, (DateTime)Command.in_Item.DateLastWrite);
                    }
                    else
                    {
                        Directory.SetLastWriteTimeUtc(DestItemPathname, (DateTime)item.DateLastWrite);
                    }
                    if (Command.in_Item.DateLastRead.HasValue)
                    {
                        Directory.SetLastAccessTimeUtc(DestItemPathname, (DateTime)Command.in_Item.DateLastRead);
                    }
                    else
                    {
                        Directory.SetLastAccessTimeUtc(DestItemPathname, (DateTime)item.DateLastRead);
                    }
                }
                else
                {
                    if (needs_move)
                    {
                        File.Move(ItemPathname, DestItemPathname);
                    }
                    if (Command.in_Item.DateCreated.HasValue)
                    {
                        File.SetCreationTimeUtc(DestItemPathname, (DateTime)Command.in_Item.DateCreated);
                    }
                    else
                    {
                        File.SetCreationTimeUtc(DestItemPathname, (DateTime)item.DateCreated);
                    }
                    if (Command.in_Item.DateLastWrite.HasValue)
                    {
                        File.SetLastWriteTimeUtc(DestItemPathname, (DateTime)Command.in_Item.DateLastWrite);
                    }
                    else
                    {
                        File.SetLastWriteTimeUtc(DestItemPathname, (DateTime)item.DateLastWrite);
                    }
                    if (Command.in_Item.DateLastRead.HasValue)
                    {
                        File.SetLastAccessTimeUtc(DestItemPathname, (DateTime)Command.in_Item.DateLastRead);
                    }
                    else
                    {
                        File.SetLastAccessTimeUtc(DestItemPathname, (DateTime)item.DateLastRead);
                    }
                }
                Command.out_Item = this.ItemFromPathname(DestItemPathname);
            }
            else
            {
                throw new Exceptions.InvalidOperationException("Update", "Item does not exist.");
            }
            return;
        }
Ejemplo n.º 6
0
 //--------------------------------------------------------------------------------
 public override void Update(Commands.UpdateItemCommand Command)
 {
     throw new NotImplementedException();
 }