return openFile(fileName, 0x00000018 | 0x00000003, attr); // SSH_FXF_CREAT | SSH_FXF_TRUNC | SSH_FXF_READ | SSH_FXF_WRITE
}
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.longValue());
if ((attr.uid != null) && (attr.gid != null))
{
tw.writeUINT32(attr.uid.intValue());
tw.writeUINT32(attr.gid.intValue());
}
if (attr.permissions != null)
tw.writeUINT32(attr.permissions.intValue());
if ((attr.atime != null) && (attr.mtime != null))
{
tw.writeUINT32(attr.atime.intValue());
tw.writeUINT32(attr.mtime.intValue());
}
}
return tw.getBytes();
}