public override void Claim(FileSystemCommandConnection connection)
		{
			if (!connection.Socket.RemoteEndPoint.Equals(this.OwnerEndPoint))
			{
				connection.WriteError(ErrorCodes.INVALID_PARAM, "ticket");

				connection.RunLevel = DisconnectedRunLevel.Default;

				return;
			}

			var src = this.file.GetContent().GetInputStream(this.fileShare);

			if (this.offset > 0 || this.length != -1)
			{
				src = new PartialStream(src, this.offset, this.length);
			}
			
			connection.WriteOk("length", src.Length.ToString(CultureInfo.InvariantCulture));
			connection.Flush();
			
			var des = connection.WriteStream;

			var pump = new StreamCopier(src, des);
        
			pump.Run();

			connection.RunLevel = DisconnectedRunLevel.Default;
		}
		public DownloadTicket(FileSystemCommandConnection connection, IFile file, FileShare fileShare, int offset, int length)
			: base(connection)
		{
			this.file = file;
			this.offset = offset;
			this.length = length;
			this.fileShare = fileShare;
		}
		public static void PrintAttribute(FileSystemCommandConnection connection, string name, object value)
		{
			var typeName = ProtocolTypes.GetTypeName(value.GetType());

			if (typeName != null)
			{
				connection.WriteTextBlock(" {0}=\"{1}:{2}\"", name,
					typeName, ProtocolTypes.ToEscapedString(value));
			}
		}
		private static void PrintNodeType(FileSystemCommandConnection connection, NodeType nodeType)
		{
			if (nodeType == NodeType.File)
			{
				connection.WriteTextPartialBlock("f");
			}
			else if (nodeType == NodeType.Directory)
			{
				connection.WriteTextPartialBlock("d");
			}
		}
		public static void PrintAttributes(FileSystemCommandConnection connection, INode node)
		{
			foreach (var keyValuePair in node.Attributes)
			{
				if (!keyValuePair.Key.EqualsIgnoreCase("exists"))
				{
					if (keyValuePair.Value != null)
					{
						PrintAttribute(connection, keyValuePair.Key, keyValuePair.Value);
					}
				}
			}
		}
Exemple #6
0
 public static void PrintAttributes(FileSystemCommandConnection connection, INode node)
 {
     foreach (var keyValuePair in node.Attributes)
     {
         if (!keyValuePair.Key.EqualsIgnoreCase("exists"))
         {
             if (keyValuePair.Value != null)
             {
                 PrintAttribute(connection, keyValuePair.Key, keyValuePair.Value);
             }
         }
     }
 }
 internal DeterministicBinaryReadContext(FileSystemCommandConnection connection)
 {
     this.acquired   = false;
     this.connection = connection;
 }
			internal DeterministicBinaryReadContext(FileSystemCommandConnection connection)
			{
				this.acquired = false;
				this.connection = connection;				
			}
Exemple #9
0
 public abstract void Claim(FileSystemCommandConnection connection);
Exemple #10
0
 protected Ticket(string ticketId, FileSystemCommandConnection connection)
 {
     this.TicketId      = ticketId;
     this.OwnerEndPoint = connection.Socket.RemoteEndPoint;
 }
Exemple #11
0
 protected Ticket(FileSystemCommandConnection connection)
     : this(NewTicketId(), connection)
 {
 }
		public abstract void Claim(FileSystemCommandConnection connection);
		protected Ticket(string ticketId, FileSystemCommandConnection connection)
		{
			this.TicketId = ticketId;
			this.OwnerEndPoint = connection.Socket.RemoteEndPoint;
		}
		protected Ticket(FileSystemCommandConnection connection)
			: this(NewTicketId(), connection)
		{
			
		}