photosite/src/tmp/index.ts

16 lines
423 B
TypeScript

import { tmpdir } from 'os';
import { join } from 'path';
import { randomBytes } from 'crypto';
const TMP : string = tmpdir();
export function tmp (ext : string = '', prefix : string = '3d-tmp-', fileName : string = null) : string {
let path : string = null;
if (fileName === null) {
fileName = prefix + randomBytes(32).toString('hex') + ext;
}
path = join(TMP, fileName);
return path;
}
module.exports = { tmp };