| 391 | } |
| 392 | |
| 393 | static int libssh_delete(URLContext *h) |
| 394 | { |
| 395 | int ret; |
| 396 | LIBSSHContext *libssh = h->priv_data; |
| 397 | sftp_attributes attr = NULL; |
| 398 | char path[MAX_URL_SIZE]; |
| 399 | |
| 400 | if ((ret = libssh_connect(h, h->filename, path, sizeof(path))) < 0) |
| 401 | goto cleanup; |
| 402 | |
| 403 | if (!(attr = sftp_stat(libssh->sftp, path))) { |
| 404 | ret = AVERROR(sftp_get_error(libssh->sftp)); |
| 405 | goto cleanup; |
| 406 | } |
| 407 | |
| 408 | if (attr->type == SSH_FILEXFER_TYPE_DIRECTORY) { |
| 409 | if (sftp_rmdir(libssh->sftp, path) < 0) { |
| 410 | ret = AVERROR(sftp_get_error(libssh->sftp)); |
| 411 | goto cleanup; |
| 412 | } |
| 413 | } else { |
| 414 | if (sftp_unlink(libssh->sftp, path) < 0) { |
| 415 | ret = AVERROR(sftp_get_error(libssh->sftp)); |
| 416 | goto cleanup; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | ret = 0; |
| 421 | |
| 422 | cleanup: |
| 423 | if (attr) |
| 424 | sftp_attributes_free(attr); |
| 425 | libssh_close(h); |
| 426 | return ret; |
| 427 | } |
| 428 | |
| 429 | static int libssh_move(URLContext *h_src, URLContext *h_dst) |
| 430 | { |
nothing calls this directly
no test coverage detected