ar_archive *ar_open_any_archive(ar_stream *stream, const char *fileext) { ar_archive *ar = ar_open_rar_archive(stream); if (!ar) ar = ar_open_zip_archive(stream, fileext && (strcmp(fileext, ".xps") == 0 || strcmp(fileext, ".epub") == 0)); if (!ar) ar = ar_open_7z_archive(stream); if (!ar) ar = ar_open_tar_archive(stream); return ar; }
bool openRarArchiveFromFile(ARCHIVE * archive, const char * path) { archive->fileHandle = ar_open_file(path); if(archive->fileHandle == NULL) { logR("Couldn't open RAR archive's file"); return false; } archive->archive = ar_open_rar_archive(archive->fileHandle); if(archive->archive == NULL) { logR("Couldn't open RAR archive"); return false; } return true; }