return openFile(fileName, SSH_FXF_CREAT | SSH_FXF_TRUNC | SSH_FXF_WRITE, attr);
}
private byte[] createAttrs(SFTPv3FileAttributes attr)
{
TypesWriter tw = new TypesWriter();
int attrFlags = 0;
if (attr == null)
{
tw.writeUINT32(0);
}
else
{
if (attr.size != null)
{
attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_SIZE;
}
if ((attr.uid != null) && (attr.gid != null))
{
attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_UIDGID;
}
if (attr.permissions != null)
{
attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_PERMISSIONS;
}
if ((attr.atime != null) && (attr.mtime != null))
{
attrFlags = attrFlags | AttribFlags.SSH_FILEXFER_ATTR_V3_ACMODTIME;
}
tw.writeUINT32(attrFlags);
if (attr.size != null)
{
tw.writeUINT64(attr.size);
}
if ((attr.uid != null) && (attr.gid != null))
{
tw.writeUINT32(attr.uid);
tw.writeUINT32(attr.gid);
}
if (attr.permissions != null)
{
tw.writeUINT32(attr.permissions);
}
if ((attr.atime != null) && (attr.mtime != null))
{
tw.writeUINT32(attr.atime);
tw.writeUINT32(attr.mtime);
}
}
return tw.getBytes();
}