chore(i18n): finish translating code comments and scripts to English
CI / Format and clippy (push) Successful in 1m57s
CI / Dependency audit (push) Successful in 13s
CI / Check desktop app (Linux) (push) Successful in 3m54s
CI / Tests (Linux) (push) Failing after 7m25s
Release / Create release (push) Successful in 6s
Release / CLI (linux-aarch64) (push) Successful in 1m48s
Release / CLI (linux-x86_64) (push) Successful in 2m39s
Release / Desktop app (linux-aarch64) (push) Successful in 10m9s
Release / Desktop app (linux-x86_64) (push) Successful in 12m20s
Release / Desktop app (windows) (push) Successful in 7m32s
Release / Build latest.json (push) Successful in 5s

Completes the English-only standardization for code, comments, scripts
and CI templates (UI/CLI-facing strings stay bilingual pt-BR/en,
untouched). Covers the remaining crates/, apps/gui/ui/ and
apps/gui/src-tauri/ comments, .gitea/ workflow and template comments,
.githooks/ hooks, and the scripts/ source comments for the files
already renamed in a prior commit (check.sh, generate-logo.py,
install-hooks.sh).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VAyr8d7HuAdUGB6aA5xmDD
This commit is contained in:
Lucas RayanandClaude Sonnet 5 committed 2026-10-30 20:43:02 -03:00
1 parent da212e6926
commit 6328220c60
129 files changed
+1961 -1834

No files matched your search

+22 -22
View File
@@ -1,13 +1,13 @@
//! Assinaturas de formatos e validação estrutural para o carving.
//! File format signatures and structural validators for file carving.
//!
//! Cada detector lê a estrutura real do arquivo (cabeçalhos, blocos, rodapés)
//! para determinar o tamanho exato e o nível de confiança, em vez de apenas
//! procurar bytes mágicos.
//! Each detector parses the internal container structure (headers, chunks, footers)
//! to determine the exact file size and confidence level rather than relying on
//! magic bytes alone.
use crate::source::{read_vec, Source};
use crate::types::{Category, Confidence};
/// Resultado de um detector: arquivo reconhecido a partir de `offset`.
/// Output of a format detector: a file recognized starting at `offset`.
#[derive(Debug, Clone)]
pub struct Hit {
pub len: u64,
@@ -37,8 +37,8 @@ pub fn category_for_ext(ext: &str) -> Category {
}
}
/// Verifica se o início do conteúdo é coerente com a extensão.
/// `None` = extensão sem assinatura conhecida (não dá para julgar).
/// Checks whether the leading bytes `head` match the expected magic for `ext`.
/// Returns `None` if `ext` has no known magic signature.
pub fn matches_ext(ext: &str, head: &[u8]) -> Option<bool> {
let ext = ext.to_ascii_lowercase();
let starts = |m: &[u8]| head.starts_with(m);
@@ -86,8 +86,8 @@ pub fn matches_ext(ext: &str, head: &[u8]) -> Option<bool> {
Some(r)
}
/// Tabela de primeiros bytes -> detectores candidatos.
/// O carving consulta `candidates(first_byte)` e chama `detect`.
/// Dispatch table mapping leading byte -> candidate format detectors.
/// The carver queries `candidates(first_byte)` and invokes `detect`.
pub fn might_start(b0: u8) -> bool {
crate::formats::might_start(b0)
|| matches!(
@@ -111,8 +111,8 @@ pub fn might_start(b0: u8) -> bool {
const MAX_HEADER: usize = 64 * 1024;
/// Tenta reconhecer um arquivo que começa em `off`.
/// `head` já contém os primeiros bytes lidos em `off` (pelo menos 16, se existirem).
/// Attempts to recognize a file starting at `off`.
/// `head` contains the leading bytes already read at `off` (at least 16 when available).
pub fn detect(src: &dyn Source, off: u64, head: &[u8], max_size: u64) -> Option<Hit> {
if head.len() < 12 {
return None;
@@ -204,7 +204,7 @@ fn jpeg(src: &dyn Source, off: u64, max: u64) -> Option<Hit> {
if !saw_sof {
return None;
}
// Dados entropy-coded: procurar EOI (FF D9) ignorando FF00 e RSTn.
// Entropy-coded scan data: scan for EOI (`FF D9`), skipping `FF 00` byte stuffing and `RSTn`.
let mut pos = off + start as u64;
let limit = off + max.min(512 * 1024 * 1024);
let mut buf = vec![0u8; 1 << 20];
@@ -230,7 +230,7 @@ fn jpeg(src: &dyn Source, off: u64, max: u64) -> Option<Hit> {
}
pos += n as u64;
}
// Sem EOI: imagem truncada/sobrescrita; ainda útil, mas incerta.
// Missing EOI: truncated or overwritten JPEG; still emit with Low confidence.
Some(Hit {
len: (pos - off).min(4 * 1024 * 1024),
ext: "jpg",
@@ -252,8 +252,8 @@ fn png(src: &dyn Source, off: u64, max: u64) -> Option<Hit> {
}
let len = u32::from_be_bytes([c[0], c[1], c[2], c[3]]) as u64;
let ty = &c[4..8];
// Bloco válido: 4 letras, 3ª maiúscula (bit reservado), tamanho plausível e dentro do
// disco. Texto ASCII solto parece "tamanho" de ~1,9 GB e não pode virar um PNG gigante.
// Valid PNG chunk: 4 ASCII letters with uppercase 3rd letter (reserved bit), plausible size within
// the source. Prevents random ASCII text after a truncated PNG from being read as a ~1.9 GB chunk.
let valid = ty.iter().all(|b| b.is_ascii_alphabetic())
&& ty[2].is_ascii_uppercase()
&& len <= 128 * 1024 * 1024
@@ -278,7 +278,7 @@ fn png(src: &dyn Source, off: u64, max: u64) -> Option<Hit> {
});
}
}
// Sem IEND: só vale como imagem truncada se já tem dados e é de tamanho razoável.
// Missing `IEND`: only keep as a truncated PNG if at least one `IDAT` was seen and size is reasonable.
if first || !saw_idat || p > 64 * 1024 * 1024 {
return None;
}
@@ -388,7 +388,7 @@ fn pdf(src: &dyn Source, off: u64, max: u64) -> Option<Hit> {
let mut i = 0;
while let Some(f) = find(&hay[i..], b"%%EOF") {
let end = base + (i + f) as u64 + 5;
// Continua se logo após o %%EOF vier uma atualização incremental.
// Continue scanning if `%%EOF` is followed by an incremental PDF update.
let tail = read_vec(src, end, 32).ok()?;
let rest: Vec<u8> = tail
.iter()
@@ -428,7 +428,7 @@ fn find(hay: &[u8], needle: &[u8]) -> Option<usize> {
hay.windows(needle.len()).position(|w| w == needle)
}
// ---------------------------------------------------------------- ZIP & derivados
// ---------------------------------------------------------------- ZIP & derivatives
fn zip(src: &dyn Source, off: u64, max: u64) -> Option<Hit> {
let limit = max.min(4 << 30);
@@ -508,7 +508,7 @@ fn classify_zip(src: &dyn Source, start: u64, names: &[String]) -> &'static str
} else if has("ppt/") {
"pptx"
} else if names.first().map(|n| n == "mimetype").unwrap_or(false) {
// O primeiro item (sem compressão) traz o tipo MIME logo após o cabeçalho.
// An uncompressed `mimetype` entry at the start identifies ODF/EPUB containers.
let head = read_vec(src, start, 256).unwrap_or_default();
let s = String::from_utf8_lossy(&head);
if s.contains("opendocument.text") {
@@ -574,7 +574,7 @@ fn isobmff(src: &dyn Source, off: u64, max: u64) -> Option<Hit> {
}
size = u64::from_be_bytes(b[8..16].try_into().unwrap());
} else if size == 0 {
// Até o fim do arquivo: tamanho desconhecido.
// Box extends to EOF: exact size unknown.
size = total - p;
}
if size < 8 || p + size > max {
@@ -705,7 +705,7 @@ pub fn crc32(data: &[u8]) -> u32 {
!crc
}
// ---------------------------------------------------------------- OLE2 (doc/xls/ppt legado)
// ---------------------------------------------------------------- OLE2 (legacy doc/xls/ppt)
fn ole(src: &dyn Source, off: u64, max: u64) -> Option<Hit> {
let hdr = read_vec(src, off, 512).ok()?;
@@ -782,7 +782,7 @@ fn mp3(src: &dyn Source, off: u64, max: u64) -> Option<Hit> {
if frames < 20 {
return None;
}
// Possível tag ID3v1 de 128 bytes ao final.
// Include optional trailing 128-byte ID3v1 tag.
if let Ok(t) = read_vec(src, off + p, 3) {
if t == b"TAG" {
p += 128;