| 132 | } |
| 133 | |
| 134 | static av_cold int libssh_open_file(LIBSSHContext *libssh, int flags, const char *file) |
| 135 | { |
| 136 | int access; |
| 137 | |
| 138 | if ((flags & AVIO_FLAG_WRITE) && (flags & AVIO_FLAG_READ)) { |
| 139 | access = O_CREAT | O_RDWR; |
| 140 | if (libssh->trunc) |
| 141 | access |= O_TRUNC; |
| 142 | } else if (flags & AVIO_FLAG_WRITE) { |
| 143 | access = O_CREAT | O_WRONLY; |
| 144 | if (libssh->trunc) |
| 145 | access |= O_TRUNC; |
| 146 | } else |
| 147 | access = O_RDONLY; |
| 148 | |
| 149 | /* 0666 = -rw-rw-rw- = read+write for everyone, minus umask */ |
| 150 | if (!(libssh->file = sftp_open(libssh->sftp, file, access, 0666))) { |
| 151 | av_log(libssh, AV_LOG_ERROR, "Error opening sftp file: %s\n", ssh_get_error(libssh->session)); |
| 152 | return AVERROR(EIO); |
| 153 | } |
| 154 | |
| 155 | return 0; |
| 156 | } |
| 157 | |
| 158 | static av_cold void libssh_stat_file(LIBSSHContext *libssh) |
| 159 | { |