node.js中检查目录是否存在
2017-12-19 08:43
731 查看
function checkDirExist(path)
{
try
{
return
fs.statSync(path).isDirectory();
}
catch
(e) {
if
(e.code
==
'ENOENT')
{ // no such
file or directory. File really does not exist
console.log("File
does not exist.");
return
false;
}
console.log("Exception
fs.statSync (" + path +
"): "
+ e);
throw
e;
// something else
went wrong, we don't have rights, ...
}
}
{
try
{
return
fs.statSync(path).isDirectory();
}
catch
(e) {
if
(e.code
==
'ENOENT')
{ // no such
file or directory. File really does not exist
console.log("File
does not exist.");
return
false;
}
console.log("Exception
fs.statSync (" + path +
"): "
+ e);
throw
e;
// something else
went wrong, we don't have rights, ...
}
}
相关文章推荐
- Node.js 中fs.access() 判断文件和目录是否存在;
- node.js 判断文件或者目录是否存在
- php中检查文件或目录是否存在的代码小结
- 检查当前目录下是否存在指定的文件,如果存在就重新命名
- 升级dedecms5.5后,出现"提示保存目录数据时失败,请检查你的输入资料是否存在问题"
- 检查目标文件夹是否存在,如果不存在则自动创建该目录
- 检查目录是否存在
- JS检查变量是否存在
- 创建目录 检查是否存在
- ios 文件操作 检查文件是否存在 创建文件目录 iphone
- Destoon5出现 请检查网站根目录下 license.txt 文件是否存在或被修改 终极解决办法
- MFC 创建目录、检查目录和文件是否存在
- JS-inArray检查数组中是否存在某个值
- asp实现检查目录是否存在与建立目录的函数
- c/c++ 检查指定目录是否存在,不存在则创建改目录
- 检查某目录或是文件是否存在 file_exists( ABSPATH . 'wp-config.php')
- php中检查文件或目录是否存在的代码小结
- 在vc6中检查一个目录是否存在,如果不存在就创建该目录
- 路由错误,请检查控制器目录下是否存在该控制器/动作