openFileToWrite
Description
Opens a file using the wx flag, which means that the file cannot exist. Although you can use this function standalone, this is to be meant to be used as a dependency of the writeFile function. Returns the file descriptor of the open file.
Parameter List | Returns | Rejection Errors |
---|---|---|
| Promise<number || Array> | |
Related Functions | Function Signature | |
function openFileToWrite(fileLocationAndName[, tuple]): Promise<string || Array> |
Examples
1
2
3
4
5
import { openFileToWrite, writeFile } from "puddy-m/lib/fileFunctions";
// The steps below can be skipped by using the createFile function.
// They are here only to illustrate how to use openFileToWrite helper function
openFileToWrite("./foo.txt") // opens file
.then(fileDescriptor=>writeFile(fileDescriptor, "Lorem Ipsum")) // writes content to file. The writeFile function closes the file.