Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/uu/sum/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ sum-about = Checksum and count the blocks in a file.

With no FILE, or when FILE is -, read standard input.
sum-usage = sum [OPTION]... [FILE]...

# Help messages
sum-help-bsd-compatible = use the BSD sum algorithm, use 1K blocks (default)
sum-help-sysv-compatible = use System V sum algorithm, use 512 bytes blocks

# Error messages
sum-error-is-directory = { $name }: Is a directory
sum-error-no-such-file-or-directory = { $name }: No such file or directory
12 changes: 12 additions & 0 deletions src/uu/sum/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sum-about = Calculer la somme de contrôle et compter les blocs dans un fichier.

Sans FICHIER, ou quand FICHIER est -, lire l'entrée standard.
sum-usage = sum [OPTION]... [FICHIER]...

# Messages d'aide
sum-help-bsd-compatible = utiliser l'algorithme de somme BSD, utiliser des blocs de 1K (par défaut)
sum-help-sysv-compatible = utiliser l'algorithme de somme System V, utiliser des blocs de 512 octets

# Messages d'erreur
sum-error-is-directory = { $name } : Est un répertoire
sum-error-no-such-file-or-directory = { $name } : Aucun fichier ou répertoire de ce type
18 changes: 12 additions & 6 deletions src/uu/sum/src/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
// spell-checker:ignore (ToDO) sysv

use clap::{Arg, ArgAction, Command};
use std::collections::HashMap;
use std::fs::File;
use std::io::{ErrorKind, Read, Write, stdin, stdout};
use std::path::Path;
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError};
use uucore::locale::{get_message, get_message_with_args};
use uucore::{format_usage, show};

use uucore::locale::get_message;

fn bsd_sum(mut reader: impl Read) -> std::io::Result<(usize, u16)> {
let mut buf = [0; 4096];
let mut bytes_read = 0;
Expand Down Expand Up @@ -74,14 +74,20 @@ fn open(name: &str) -> UResult<Box<dyn Read>> {
if path.is_dir() {
return Err(USimpleError::new(
2,
format!("{}: Is a directory", name.maybe_quote()),
get_message_with_args(
"sum-error-is-directory",
HashMap::from([("name".to_string(), name.maybe_quote().to_string())]),
),
));
};
// Silent the warning as we want to the error message
if path.metadata().is_err() {
return Err(USimpleError::new(
2,
format!("{}: No such file or directory", name.maybe_quote()),
get_message_with_args(
"sum-error-no-such-file-or-directory",
HashMap::from([("name".to_string(), name.maybe_quote().to_string())]),
),
));
};
let f = File::open(path).map_err_context(String::new)?;
Expand Down Expand Up @@ -149,14 +155,14 @@ pub fn uu_app() -> Command {
.arg(
Arg::new(options::BSD_COMPATIBLE)
.short('r')
.help("use the BSD sum algorithm, use 1K blocks (default)")
.help(get_message("sum-help-bsd-compatible"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::SYSTEM_V_COMPATIBLE)
.short('s')
.long(options::SYSTEM_V_COMPATIBLE)
.help("use System V sum algorithm, use 512 bytes blocks")
.help(get_message("sum-help-sysv-compatible"))
.action(ArgAction::SetTrue),
)
}
Loading