internal static NSch.SftpATTRS GetATTR(Buffer buf)
 {
     NSch.SftpATTRS attr = new NSch.SftpATTRS();
     attr.flags = buf.GetInt();
     if ((attr.flags & SSH_FILEXFER_ATTR_SIZE) != 0)
     {
         attr.size = buf.GetLong();
     }
     if ((attr.flags & SSH_FILEXFER_ATTR_UIDGID) != 0)
     {
         attr.uid = buf.GetInt();
         attr.gid = buf.GetInt();
     }
     if ((attr.flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0)
     {
         attr.permissions = buf.GetInt();
     }
     if ((attr.flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0)
     {
         attr.atime = buf.GetInt();
     }
     if ((attr.flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0)
     {
         attr.mtime = buf.GetInt();
     }
     if ((attr.flags & SSH_FILEXFER_ATTR_EXTENDED) != 0)
     {
         int count = buf.GetInt();
         if (count > 0)
         {
             attr.extended = new string[count * 2];
             for (int i = 0; i < count; i++)
             {
                 attr.extended[i * 2]     = Util.Byte2str(buf.GetString());
                 attr.extended[i * 2 + 1] = Util.Byte2str(buf.GetString());
             }
         }
     }
     return(attr);
 }
Example #2
0
			internal virtual void SetAttrs(SftpATTRS attrs)
			{
				this.attrs = attrs;
			}
Example #3
0
			internal LsEntry(ChannelSftp _enclosing, string filename, string longname, SftpATTRS
				 attrs)
			{
				this._enclosing = _enclosing;
				this.SetFilename(filename);
				this.SetLongname(longname);
				this.SetAttrs(attrs);
			}
Example #4
0
		/// <exception cref="System.Exception"></exception>
		private void SendMKDIR(byte[] path, SftpATTRS attr)
		{
			packet.Reset();
			PutHEAD(SSH_FXP_MKDIR, 9 + path.Length + (attr != null ? attr.Length() : 4));
			buf.PutInt(seq++);
			buf.PutString(path);
			// path
			if (attr != null)
			{
				attr.Dump(buf);
			}
			else
			{
				buf.PutInt(0);
			}
			GetSession().Write(packet, this, 9 + path.Length + (attr != null ? attr.Length() : 
				4) + 4);
		}
Example #5
0
		/// <exception cref="System.Exception"></exception>
		private void SendSETSTAT(byte[] path, SftpATTRS attr)
		{
			packet.Reset();
			PutHEAD(SSH_FXP_SETSTAT, 9 + path.Length + attr.Length());
			buf.PutInt(seq++);
			buf.PutString(path);
			// path
			attr.Dump(buf);
			GetSession().Write(packet, this, 9 + path.Length + attr.Length() + 4);
		}
Example #6
0
		/// <exception cref="NSch.SftpException"></exception>
		private void _setStat(string path, SftpATTRS attr)
		{
			try
			{
				SendSETSTAT(Util.Str2byte(path, fEncoding), attr);
				ChannelHeader header = new ChannelHeader(this);
				header = Header(buf, header);
				int length = header.length;
				int type = header.type;
				Fill(buf, length);
				if (type != SSH_FXP_STATUS)
				{
					throw new SftpException(SSH_FX_FAILURE, string.Empty);
				}
				int i = buf.GetInt();
				if (i != SSH_FX_OK)
				{
					ThrowStatusError(buf, i);
				}
			}
			catch (Exception e)
			{
				if (e is SftpException)
				{
					throw (SftpException)e;
				}
				if (e is Exception)
				{
					throw new SftpException(SSH_FX_FAILURE, string.Empty, (Exception)e);
				}
				throw new SftpException(SSH_FX_FAILURE, string.Empty);
			}
		}
Example #7
0
		/// <exception cref="NSch.SftpException"></exception>
		public virtual void SetStat(string path, SftpATTRS attr)
		{
			try
			{
				path = RemoteAbsolutePath(path);
				ArrayList v = Glob_remote(path);
				int vsize = v.Count;
				for (int j = 0; j < vsize; j++)
				{
					path = (string)(v[j]);
					_setStat(path, attr);
				}
			}
			catch (Exception e)
			{
				if (e is SftpException)
				{
					throw (SftpException)e;
				}
				if (e is Exception)
				{
					throw new SftpException(SSH_FX_FAILURE, string.Empty, (Exception)e);
				}
				throw new SftpException(SSH_FX_FAILURE, string.Empty);
			}
		}
Example #8
0
		internal static NSch.SftpATTRS GetATTR(Buffer buf)
		{
			NSch.SftpATTRS attr = new NSch.SftpATTRS();
			attr.flags = buf.GetInt();
			if ((attr.flags & SSH_FILEXFER_ATTR_SIZE) != 0)
			{
				attr.size = buf.GetLong();
			}
			if ((attr.flags & SSH_FILEXFER_ATTR_UIDGID) != 0)
			{
				attr.uid = buf.GetInt();
				attr.gid = buf.GetInt();
			}
			if ((attr.flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0)
			{
				attr.permissions = buf.GetInt();
			}
			if ((attr.flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0)
			{
				attr.atime = buf.GetInt();
			}
			if ((attr.flags & SSH_FILEXFER_ATTR_ACMODTIME) != 0)
			{
				attr.mtime = buf.GetInt();
			}
			if ((attr.flags & SSH_FILEXFER_ATTR_EXTENDED) != 0)
			{
				int count = buf.GetInt();
				if (count > 0)
				{
					attr.extended = new string[count * 2];
					for (int i = 0; i < count; i++)
					{
						attr.extended[i * 2] = Util.Byte2str(buf.GetString());
						attr.extended[i * 2 + 1] = Util.Byte2str(buf.GetString());
					}
				}
			}
			return attr;
		}