//--------------------------------------------------------------------- public override void WriteFileContent(Commands.WriteFileContentCommand Command) { //if( this._Root.Length == 0 ) { throw new Exceptions.InvalidOperationException( "WriteContent", "FileSystem root is undefined" ); } //string syspath = this.MakeSystemPathname( this._Root, Command.in_Pathname ); //FileSystemItem item = this.ItemFromPathname( item_path_name ); //if( item.IsFolder ) //{ // throw new Exceptions.InvalidOperationException( "WriteContent", "Cannot write content to a folder." ); //} //else //{ // using( FileStream stream = File.OpenWrite( item_path_name ) ) // { // if( (Command.in_Offset < 0) || (Command.in_Offset >= stream.Length) ) // { throw new Exceptions.InvalidOperationException( "WriteContent", "Offset is outside of expected range." ); } // stream.Position = Command.in_Offset; // stream.Write( Command.in_Content, 0, Command.in_Content.Length ); // if( Command.in_Truncate ) // { stream.SetLength( stream.Position ); } // } // Command.out_Item = this.ItemFromPathname( item_path_name ); // return; //} //$Command = "put -preservetime " + $Record.LocalPath + " " + $ThisRemoteFolder + '/' //$Lines = WinScp-Command $ThisConnectionString $Command $False return; }
//--------------------------------------------------------------------- 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; }
//--------------------------------------------------------------------- public override void WriteFileContent(Commands.WriteFileContentCommand Command) { if (this._Root.Length == 0) { throw new Exceptions.InvalidOperationException("WriteContent", "FileSystem root is undefined"); } Pathname ItemPathname = Pathname.Append(this._Root, Command.in_Pathname); using (FileStream stream = File.OpenWrite(ItemPathname)) { if ((Command.in_Offset < 0) || (Command.in_Offset >= stream.Length)) { throw new Exceptions.InvalidOperationException("WriteContent", "Offset is outside of expected range."); } stream.Position = Command.in_Offset; stream.Write(Command.in_Content, 0, Command.in_Content.Length); if (Command.in_Truncate) { stream.SetLength(stream.Position); } } Command.out_Item = this.ItemFromPathname(ItemPathname); return; }
public abstract void WriteFileContent(Commands.WriteFileContentCommand Command);
//--------------------------------------------------------------------- public FileSystemItem WriteFileContent(string Pathname, int Offset, byte[] Content, bool Truncate) { Commands.WriteFileContentCommand WriteContentCommand = new Commands.WriteFileContentCommand(Pathname, Offset, Content, Truncate); this.WriteFileContent(WriteContentCommand); return(WriteContentCommand.out_Item); }
//-------------------------------------------------------------------------------- public override void WriteFileContent(Commands.WriteFileContentCommand Command) { throw new NotImplementedException(); }