const path = require('node:path');
//根据不同操作系统中的路径分隔符,组成新的文件路径
console.log(path.join('./node','module','app.js')); //node\module\app.js

//根据不同操作系统中的路径分隔符,返回绝对路径的文件
console.log(path.resolve('file.js'));//D:\git\note\webstrom\node\模块-文件操作\file.js

// 返回文件名中最后部分,一般是文件名。
console.log(path.basename('./src/module/app.js')); //app.js

//返回文件中的目录部分
console.log(path.dirname('./src/module/app.js')); // ./src/module

// 判断路径是否是绝对路径
console.log(path.isAbsolute('./src/module/app.js')) //false
console.log(path.isAbsolute('/etc')) //true

// 返回文件名的扩展名
console.log(path.extname('./src/module/app.js')); //.js

//获取文件信息
console.log(path.parse('./file.js'));// { root: '', dir: '.', base: 'file.js', ext: '.js', name: 'file' }