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
45 changes: 45 additions & 0 deletions src/uu/split/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,48 @@ split-after-help = Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...;
- l/K/N output Kth of N to stdout without splitting lines/records
- r/N like 'l' but use round robin distribution
- r/K/N likewise but only output Kth of N to stdout

# Error messages
split-error-suffix-not-parsable = invalid suffix length: { $value }
split-error-suffix-contains-separator = invalid suffix { $value }, contains directory separator
split-error-suffix-too-small = the suffix length needs to be at least { $length }
split-error-multi-character-separator = multi-character separator { $separator }
split-error-multiple-separator-characters = multiple separator characters specified
split-error-filter-with-kth-chunk = --filter does not process a chunk extracted to stdout
split-error-invalid-io-block-size = invalid IO block size: { $size }
split-error-not-supported = --filter is currently not supported in this platform
split-error-invalid-number-of-chunks = invalid number of chunks: { $chunks }
split-error-invalid-chunk-number = invalid chunk number: { $chunk }
split-error-invalid-number-of-lines = invalid number of lines: { $error }
split-error-invalid-number-of-bytes = invalid number of bytes: { $error }
split-error-cannot-split-more-than-one-way = cannot split in more than one way
split-error-overflow = Overflow
split-error-output-file-suffixes-exhausted = output file suffixes exhausted
split-error-numerical-suffix-start-too-large = numerical suffix start value is too large for the suffix length
split-error-cannot-open-for-reading = cannot open { $file } for reading
split-error-would-overwrite-input = { $file } would overwrite input; aborting
split-error-cannot-determine-input-size = { $input }: cannot determine input size
split-error-cannot-determine-file-size = { $input }: cannot determine file size
split-error-cannot-read-from-input = { $input }: cannot read from input : { $error }
split-error-input-output-error = input/output error
split-error-unable-to-open-file = unable to open { $file }; aborting
split-error-unable-to-reopen-file = unable to re-open { $file }; aborting
split-error-file-descriptor-limit = at file descriptor limit, but no file descriptor left to close. Closed { $count } writers before.
split-error-shell-process-returned = Shell process returned { $code }
split-error-shell-process-terminated = Shell process terminated by signal

# Help messages for command-line options
split-help-bytes = put SIZE bytes per output file
split-help-line-bytes = put at most SIZE bytes of lines per output file
split-help-lines = put NUMBER lines/records per output file
split-help-number = generate CHUNKS output files; see explanation below
split-help-additional-suffix = additional SUFFIX to append to output file names
split-help-filter = write to shell COMMAND; file name is $FILE (Currently not implemented for Windows)
split-help-elide-empty-files = do not generate empty output files with '-n'
split-help-numeric-suffixes-short = use numeric suffixes starting at 0, not alphabetic
split-help-numeric-suffixes = same as -d, but allow setting the start value
split-help-hex-suffixes-short = use hex suffixes starting at 0, not alphabetic
split-help-hex-suffixes = same as -x, but allow setting the start value
split-help-suffix-length = generate suffixes of length N (default 2)
split-help-verbose = print a diagnostic just before each output file is opened
split-help-separator = use SEP instead of newline as the record separator; '\\0' (zero) specifies the NUL character
61 changes: 61 additions & 0 deletions src/uu/split/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
split-about = Créer des fichiers de sortie contenant des sections consécutives ou entrelacées de l'entrée
split-usage = split [OPTION]... [ENTRÉE [PRÉFIXE]]
split-after-help = Sortir des morceaux de taille fixe d'ENTRÉE vers PREFIXEaa, PREFIXEab, ...; la taille par défaut est 1000, et le PRÉFIXE par défaut est 'x'. Sans ENTRÉE, ou quand ENTRÉE est -, lire l'entrée standard.

L'argument TAILLE est un entier et une unité optionnelle (exemple: 10K est 10*1024).
Les unités sont K,M,G,T,P,E,Z,Y,R,Q (puissances de 1024) ou KB,MB,... (puissances de 1000).
Les préfixes binaires peuvent être utilisés aussi: KiB=K, MiB=M, et ainsi de suite.

CHUNKS peut être:

- N diviser en N fichiers basé sur la taille de l'entrée
- K/N sortir le Kème de N vers stdout
- l/N diviser en N fichiers sans diviser les lignes/enregistrements
- l/K/N sortir le Kème de N vers stdout sans diviser les lignes/enregistrements
- r/N comme 'l' mais utiliser la distribution round robin
- r/K/N pareillement mais ne sortir que le Kème de N vers stdout

# Messages d'erreur
split-error-suffix-not-parsable = longueur de suffixe invalide : { $value }
split-error-suffix-contains-separator = suffixe invalide { $value }, contient un séparateur de répertoire
split-error-suffix-too-small = la longueur du suffixe doit être au moins { $length }
split-error-multi-character-separator = séparateur multi-caractères { $separator }
split-error-multiple-separator-characters = plusieurs caractères de séparateur spécifiés
split-error-filter-with-kth-chunk = --filter ne traite pas un chunk extrait vers stdout
split-error-invalid-io-block-size = taille de bloc IO invalide : { $size }
split-error-not-supported = --filter n'est actuellement pas supporté sur cette plateforme
split-error-invalid-number-of-chunks = nombre de chunks invalide : { $chunks }
split-error-invalid-chunk-number = numéro de chunk invalide : { $chunk }
split-error-invalid-number-of-lines = nombre de lignes invalide : { $error }
split-error-invalid-number-of-bytes = nombre d'octets invalide : { $error }
split-error-cannot-split-more-than-one-way = impossible de diviser de plus d'une façon
split-error-overflow = Débordement
split-error-output-file-suffixes-exhausted = suffixes de fichiers de sortie épuisés
split-error-numerical-suffix-start-too-large = la valeur de départ du suffixe numérique est trop grande pour la longueur du suffixe
split-error-cannot-open-for-reading = impossible d'ouvrir { $file } en lecture
split-error-would-overwrite-input = { $file } écraserait l'entrée ; abandon
split-error-cannot-determine-input-size = { $input } : impossible de déterminer la taille de l'entrée
split-error-cannot-determine-file-size = { $input } : impossible de déterminer la taille du fichier
split-error-cannot-read-from-input = { $input } : impossible de lire depuis l'entrée : { $error }
split-error-input-output-error = erreur d'entrée/sortie
split-error-unable-to-open-file = impossible d'ouvrir { $file } ; abandon
split-error-unable-to-reopen-file = impossible de rouvrir { $file } ; abandon
split-error-file-descriptor-limit = limite de descripteurs de fichiers atteinte, mais aucun descripteur de fichier à fermer. { $count } écrivains fermés auparavant.
split-error-shell-process-returned = Le processus shell a retourné { $code }
split-error-shell-process-terminated = Le processus shell a été terminé par un signal

# Messages d'aide pour les options de ligne de commande
split-help-bytes = mettre TAILLE octets par fichier de sortie
split-help-line-bytes = mettre au maximum TAILLE octets de lignes par fichier de sortie
split-help-lines = mettre NOMBRE lignes/enregistrements par fichier de sortie
split-help-number = générer CHUNKS fichiers de sortie ; voir l'explication ci-dessous
split-help-additional-suffix = SUFFIXE supplémentaire à ajouter aux noms de fichiers de sortie
split-help-filter = écrire vers la COMMANDE shell ; le nom de fichier est $FILE (Actuellement non implémenté pour Windows)
split-help-elide-empty-files = ne pas générer de fichiers de sortie vides avec '-n'
split-help-numeric-suffixes-short = utiliser des suffixes numériques commençant à 0, pas alphabétiques
split-help-numeric-suffixes = identique à -d, mais permet de définir la valeur de départ
split-help-hex-suffixes-short = utiliser des suffixes hexadécimaux commençant à 0, pas alphabétiques
split-help-hex-suffixes = identique à -x, mais permet de définir la valeur de départ
split-help-suffix-length = générer des suffixes de longueur N (par défaut 2)
split-help-verbose = afficher un diagnostic juste avant l'ouverture de chaque fichier de sortie
split-help-separator = utiliser SEP au lieu de nouvelle ligne comme séparateur d'enregistrement ; '\\0' (zéro) spécifie le caractère NUL
10 changes: 6 additions & 4 deletions src/uu/split/src/filenames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
OPT_NUMERIC_SUFFIXES_SHORT, OPT_SUFFIX_LENGTH,
};
use clap::ArgMatches;
use std::collections::HashMap;
use std::path::is_separator;
use thiserror::Error;
use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError};
use uucore::locale::{get_message, get_message_with_args};

/// The format to use for suffixes in the filename for each output chunk.
#[derive(Clone, Copy)]
Expand Down Expand Up @@ -82,15 +84,15 @@
#[derive(Debug, Error)]
pub enum SuffixError {
/// Invalid suffix length parameter.
#[error("invalid suffix length: {}", .0.quote())]
#[error("{}", get_message_with_args("split-error-suffix-not-parsable", HashMap::from([("value".to_string(), .0.quote().to_string())])))]
NotParsable(String),

/// Suffix contains a directory separator, which is not allowed.
#[error("invalid suffix {}, contains directory separator", .0.quote())]
#[error("{}", get_message_with_args("split-error-suffix-contains-separator", HashMap::from([("value".to_string(), .0.quote().to_string())])))]
ContainsSeparator(String),

/// Suffix is not large enough to split into specified chunks
#[error("the suffix length needs to be at least {0}")]
#[error("{}", get_message_with_args("split-error-suffix-too-small", HashMap::from([("length".to_string(), .0.to_string())])))]
TooSmall(usize),
}

Expand Down Expand Up @@ -315,7 +317,7 @@
FixedWidthNumber::new(radix, suffix.length, suffix.start).map_err(|_| {
USimpleError::new(
1,
"numerical suffix start value is too large for the suffix length",
get_message("split-error-numerical-suffix-start-too-large"),

Check warning on line 320 in src/uu/split/src/filenames.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/split/src/filenames.rs#L320

Added line #L320 was not covered by tests
)
})?,
)
Expand Down
3 changes: 2 additions & 1 deletion src/uu/split/src/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
//! [positional notation]: https://en.wikipedia.org/wiki/Positional_notation
use std::error::Error;
use std::fmt::{self, Display, Formatter};
use uucore::locale::get_message;

/// An overflow due to incrementing a number beyond its representable limit.
#[derive(Debug)]
pub struct Overflow;

impl Display for Overflow {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "Overflow")
write!(f, "{}", get_message("split-error-overflow"))

Check warning on line 27 in src/uu/split/src/number.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/split/src/number.rs#L27

Added line #L27 was not covered by tests
}
}

Expand Down
24 changes: 20 additions & 4 deletions src/uu/split/src/platform/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use std::collections::HashMap;
use std::env;
use std::io::Write;
use std::io::{BufWriter, Error, Result};
Expand All @@ -10,6 +11,7 @@
use uucore::error::USimpleError;
use uucore::fs;
use uucore::fs::FileInformation;
use uucore::locale::get_message_with_args;
use uucore::show;

/// A writer that writes to a shell_process' stdin
Expand Down Expand Up @@ -110,11 +112,17 @@
if return_code != 0 {
show!(USimpleError::new(
1,
format!("Shell process returned {return_code}")
get_message_with_args(
"split-error-shell-process-returned",
HashMap::from([("code".to_string(), return_code.to_string())])
)
));
}
} else {
show!(USimpleError::new(1, "Shell process terminated by signal"));
show!(USimpleError::new(
1,
get_message_with_args("split-error-shell-process-terminated", HashMap::new())
));

Check warning on line 125 in src/uu/split/src/platform/unix.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/split/src/platform/unix.rs#L122-L125

Added lines #L122 - L125 were not covered by tests
}
}
}
Expand All @@ -134,14 +142,22 @@
.create(true)
.truncate(true)
.open(Path::new(&filename))
.map_err(|_| Error::other(format!("unable to open '{filename}'; aborting")))?
.map_err(|_| {
Error::other(get_message_with_args(
"split-error-unable-to-open-file",
HashMap::from([("file".to_string(), filename.to_string())]),
))
})?
} else {
// re-open file that we previously created to append to it
std::fs::OpenOptions::new()
.append(true)
.open(Path::new(&filename))
.map_err(|_| {
Error::other(format!("unable to re-open '{filename}'; aborting"))
Error::other(get_message_with_args(
"split-error-unable-to-reopen-file",
HashMap::from([("file".to_string(), filename.to_string())]),
))
})?
};
Ok(BufWriter::new(Box::new(file) as Box<dyn Write>))
Expand Down
16 changes: 14 additions & 2 deletions src/uu/split/src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use std::collections::HashMap;
use std::io::Write;
use std::io::{BufWriter, Error, Result};
use std::path::Path;
use uucore::fs;
use uucore::locale::get_message_with_args;

/// Get a file writer
///
Expand All @@ -23,13 +25,23 @@ pub fn instantiate_current_writer(
.create(true)
.truncate(true)
.open(Path::new(&filename))
.map_err(|_| Error::other(format!("unable to open '{filename}'; aborting")))?
.map_err(|_| {
Error::other(get_message_with_args(
"split-error-unable-to-open-file",
HashMap::from([("file".to_string(), filename.to_string())]),
))
})?
} else {
// re-open file that we previously created to append to it
std::fs::OpenOptions::new()
.append(true)
.open(Path::new(&filename))
.map_err(|_| Error::other(format!("unable to re-open '{filename}'; aborting")))?
.map_err(|_| {
Error::other(get_message_with_args(
"split-error-unable-to-reopen-file",
HashMap::from([("file".to_string(), filename.to_string())]),
))
})?
};
Ok(BufWriter::new(Box::new(file) as Box<dyn Write>))
}
Expand Down
Loading
Loading