Skip to content

truncate

Reduit ou etend un fichier a une taille donnée.

Exemple

ts
import { 
SF
} from "@duplojs/server-utils";
const
cleared
= await
SF
.
truncate
("/tmp/file.bin", 0);
// cleared: E.Ok | SF.FileSystemLeft await
SF
.
truncate
("/tmp/file.bin", 128);

Syntaxe

typescript
function truncate(
  path: string | URL,
  size?: number
): Promise<FileSystemLeft | E.Ok>

Paramètres

  • path : chemin du fichier.
  • size : nouvelle taille en octets (optionnel).

Valeur de retour

  • E.Ok : si l'opération réussit.
  • FileSystemLeft : si l'opération échoue.

Voir aussi

  • writeFile - Écrit un contenu binaire dans un fichier.

Diffusé sous licence MIT.