mirror of
https://github.com/modrinth/code.git
synced 2026-08-26 09:34:50 +00:00
36 lines
863 B
Rust
36 lines
863 B
Rust
use crate::validate::{
|
|
SupportedGameVersions, ValidationError, ValidationResult,
|
|
validate_pack_formats,
|
|
};
|
|
use std::io::Cursor;
|
|
use zip::ZipArchive;
|
|
|
|
pub struct RiftValidator;
|
|
|
|
impl super::Validator for RiftValidator {
|
|
fn get_file_extensions(&self) -> &[&str] {
|
|
&["jar"]
|
|
}
|
|
|
|
fn get_supported_loaders(&self) -> &[&str] {
|
|
&["rift"]
|
|
}
|
|
|
|
fn get_supported_game_versions(&self) -> SupportedGameVersions {
|
|
SupportedGameVersions::All
|
|
}
|
|
|
|
fn validate(
|
|
&self,
|
|
archive: &mut ZipArchive<Cursor<bytes::Bytes>>,
|
|
) -> Result<ValidationResult, ValidationError> {
|
|
if archive.by_name("riftmod.json").is_err() {
|
|
return Ok(ValidationResult::Warning(
|
|
"No riftmod.json present for Rift file.",
|
|
));
|
|
}
|
|
|
|
Ok(validate_pack_formats(archive))
|
|
}
|
|
}
|