1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-13 04:42:23 +03:00

Reformat of sftp_rename() to match the current coding style

Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Eshan Kelkar
2023-04-20 22:04:43 +05:30
committed by Jakub Jelen
parent 73c3d8965d
commit b067d7a123

View File

@@ -2514,10 +2514,11 @@ int sftp_mkdir(sftp_session sftp, const char *directory, mode_t mode)
} }
/* code written by nick */ /* code written by nick */
int sftp_rename(sftp_session sftp, const char *original, const char *newname) { int sftp_rename(sftp_session sftp, const char *original, const char *newname)
{
sftp_status_message status = NULL; sftp_status_message status = NULL;
sftp_message msg = NULL; sftp_message msg = NULL;
ssh_buffer buffer; ssh_buffer buffer = NULL;
uint32_t id; uint32_t id;
int rc; int rc;
@@ -2542,17 +2543,19 @@ int sftp_rename(sftp_session sftp, const char *original, const char *newname) {
return -1; return -1;
} }
if (sftp->version >= 4){ if (sftp->version >= 4) {
/* POSIX rename atomically replaces newpath, we should do the same /*
* only available on >=v4 */ * POSIX rename atomically replaces newpath,
* we should do the same only available on >=v4
*/
ssh_buffer_add_u32(buffer, SSH_FXF_RENAME_OVERWRITE); ssh_buffer_add_u32(buffer, SSH_FXF_RENAME_OVERWRITE);
} }
if (sftp_packet_write(sftp, SSH_FXP_RENAME, buffer) < 0) { rc = sftp_packet_write(sftp, SSH_FXP_RENAME, buffer);
SSH_BUFFER_FREE(buffer); SSH_BUFFER_FREE(buffer);
if (rc < 0) {
return -1; return -1;
} }
SSH_BUFFER_FREE(buffer);
while (msg == NULL) { while (msg == NULL) {
if (sftp_read_and_dispatch(sftp) < 0) { if (sftp_read_and_dispatch(sftp) < 0) {
@@ -2577,8 +2580,8 @@ int sftp_rename(sftp_session sftp, const char *original, const char *newname) {
break; break;
} }
/* /*
* Status should be SSH_FX_OK if the command was successful, if it didn't, * Status should be SSH_FX_OK if the command was successful,
* then there was an error * if it didn't, then there was an error
*/ */
ssh_set_error(sftp->session, SSH_REQUEST_DENIED, ssh_set_error(sftp->session, SSH_REQUEST_DENIED,
"SFTP server: %s", status->errormsg); "SFTP server: %s", status->errormsg);