| 29 | } |
| 30 | |
| 31 | static AVIOContext *ffms_fopen(const char *filename, const char *mode) { |
| 32 | int flags = 0; |
| 33 | if (strchr(mode, 'r')) |
| 34 | flags |= AVIO_FLAG_READ; |
| 35 | if (strchr(mode, 'w')) |
| 36 | flags |= AVIO_FLAG_WRITE; |
| 37 | |
| 38 | AVIOContext *ctx; |
| 39 | int ret = avio_open2(&ctx, filename, flags, nullptr, nullptr); |
| 40 | if (ret < 0) |
| 41 | return nullptr; |
| 42 | return ctx; |
| 43 | } |
| 44 | |
| 45 | FileHandle::FileHandle(const char *filename, const char *mode, int error_source, int error_cause) |
| 46 | : avio(ffms_fopen(filename, mode)) |