totjs
Version:
Markup-like Database without Indexing
30 lines (28 loc) • 634 B
JavaScript
import { printError } from './printError.js';
import fs from 'fs/promises';
export async function createFile(filename)
{
try
{
if (!filename)
{
printError("File path may not be appropriate");
return false;
}
try
{
await fs.access(filename);
printError(`${ filename } exists`);
return false;
}
catch {
await fs.writeFile(filename, '');
return true;
}
}
catch (error)
{
printError(error.toString());
return false;
}
}