Skip to content

Commit

Permalink
pathName & Stats ✅
Browse files Browse the repository at this point in the history
  • Loading branch information
xgqfrms committed Aug 20, 2024
1 parent a2b327d commit 9b75e37
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 6 deletions.
3 changes: 3 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ <h1>ielts-guide-2nd</h1>
<br />
<a href="https://ielts-guide-2nd.xgqfrms.xyz/%E3%80%8A%E9%9B%85%E6%80%9D%E8%80%83%E8%AF%95%E5%AE%98%E6%96%B9%E6%8C%87%E5%8D%97%E3%80%8B%EF%BC%88%E7%AC%AC2%E7%89%88%EF%BC%89/%E5%9B%BE%E4%B9%A6%E4%BB%8B%E7%BB%8D.mp4">《雅思考试官方指南》(第2版)/图书介绍.mp4</a>
</section>
<div>
<a href="https://ielts-guide-2nd.xgqfrms.xyz/《雅思考试官方指南》(第2版)/视频:口语考试实况录像/01 Speaking Sample 1.mp4">视频:口语考试实况录像/01 Speaking Sample 1.mp4</a>
</div>

<article>
<!-- todos
Expand Down
68 changes: 68 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.1",
"description": "雅思考试官方指南(第2版)音频、视频资源",
"main": "src/index.ts",
"type": "module",
"scripts": {
"dev": "tsc -p tsconfig.json",
"build": "tsc -p tsconfig.build.json",
Expand All @@ -24,13 +25,7 @@
},
"homepage": "https://github.com/xgqfrms/IELTS-Guide-2nd#readme",
"devDependencies": {
"@types/dedent": "^0.7.0",
"@types/node": "^18.7.3",
"typescript": "^4.7.4"
},
"dependencies": {
"@actions/core": "^1.9.1",
"@actions/github": "^5.0.3",
"dedent": "^0.7.0"
}
}
89 changes: 89 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import fs, {stat} from 'node:fs';
import path from 'node:path';



const rootFolder = '/Users/xgqfrms-mm/Documents/github/IELTS-Guide-2th/docs/《雅思考试官方指南》(第2版)';


const isFile = fileName => {
return fs.lstatSync(fileName).isFile() || false;
};
const isFolder = fileName => {
return fs.lstatSync(fileName).isDirectory() || false;
};

try {
// 读取文件夹
fs.readdirSync(rootFolder).map(fileName => {
console.log(`❓ fileName =`, fileName);
const pathName = path.join(rootFolder, fileName);
stat(pathName, (err, stats) => {
// console.log(stats);
// Stats {
// dev: 16777220,
// mode: 16877,
// nlink: 12,
// uid: 501,
// gid: 20,
// rdev: 0,
// blksize: 4096,
// ino: 64334171,
// size: 384,
// blocks: 0,
// atimeMs: 1723572008018.5503,
// mtimeMs: 1723572008013.725,
// ctimeMs: 1723572008013.725,
// birthtimeMs: 1723570190954.7646,
// atime: 2024-08-13T18:00:08.019Z,
// mtime: 2024-08-13T18:00:08.014Z,
// ctime: 2024-08-13T18:00:08.014Z,
// birthtime: 2024-08-13T17:29:50.955Z
// }
console.log(stats.isDirectory());
});
// if(isFolder(fileName)) {
// console.log(`🗂️ folderName =`, fileName)
// } else {
// console.log(`📂 fileName =`, fileName)
// }
// if(isFile(fileName)) {
// console.log(`📂 fileName =`, fileName)
// } else {
// console.log(`🗂️ folderName =`, fileName)
// }
// let temp = path.join(folderPath, fileName);
});
} catch (err) {
console.error(`error ❌ =`, err);
}


// try {
// if (!fs.existsSync(rootFolder)) {
// fs.mkdirSync(folderName);
// }
// } catch (err) {
// console.error(err);
// }



/*
https://nodejs.org/api/fs.html#fslstatsyncpath-options
http://man7.org/linux/man-pages/man2/lstat.2.html
stat, fstat, lstat, fstatat (get file status)
https://nodejs.org/api/fs.html#fsstatpath-options-callback
// __dirname
https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-js-when-using-es6-modules
*/

0 comments on commit 9b75e37

Please sign in to comment.