ensureFile
S'assure qu'un fichier existe.
Exemple
ts
import { SF } from "@duplojs/server-utils";
import { E } from "@duplojs/utils";
const result = await SF.ensureFile("/tmp/empty.txt");
// result: E.Ok | SF.FileSystemLeft
if (E.isRight(result)) {
// if the file already exists, nothing happens (create if not exist)
}Syntaxe
typescript
function ensureFile(
path: string | URL
): Promise<FileSystemLeft | E.Ok>Paramètres
path: chemin du fichier.
Valeur de retour
E.Ok: si le fichier existe ou a ete crée.FileSystemLeft: si l'opération échoue.
Voir aussi
ensureDirectory- S'assure qu'un dossier existe.
