mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
29 lines
610 B
TypeScript
29 lines
610 B
TypeScript
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
export function getFileContentByName(fileName: string) {
|
|
if (fs.existsSync(fileName)) {
|
|
return fs.readFileSync(fileName, 'utf8');
|
|
}
|
|
return '';
|
|
}
|
|
|
|
export function getLastModifyFilePath(dir: string) {
|
|
let filePath = '';
|
|
|
|
if (fs.existsSync(dir)) {
|
|
const arr = fs.readdirSync(dir);
|
|
|
|
arr.forEach((item) => {
|
|
var fullpath = path.join(dir, item);
|
|
var stats = fs.statSync(fullpath);
|
|
if (stats.isFile()) {
|
|
if (stats.mtimeMs >= 0) {
|
|
filePath = fullpath;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return filePath;
|
|
}
|