nodejs(四)file System模块 解决Cross device link错误 EXDEV
2013-08-24 00:07
232 查看
var fs = require('fs'); /*cross device link fs.rename('c:\\err.LOG','d:\\err.LOG',function(err){ console.log(err.code); }); */ move('c:\\err.LOG','d:\\err.LOG',function(err){ if(err) throw err; }); function move(oldpath,newpath,callback){ fs.rename(oldpath,newpath,function(err){ if(err){ if(err.code === 'EXDEV'){ copy(); }else{ callback(err); } }else{ callback(); } }); function copy(){ var readStream = fs.createReadStream(oldpath); var writeStream = fs.createWriteStream(newpath); readStream.on('error',callback); writeStream.on('error',callback); readStream.on('close',function(){ fs.unlink(oldpath,callback); }); } }
相关文章推荐
- 【Nodejs项目手记】Nodejs中使用图片验证码,captchapng模块可以解决Nodejs图
- npm安装nodejs模块时,有些模块因为墙的原因无法安装,可以使用指定代理来解决。
- 解决Nodejs全局安装模块后找不到命令的问题
- 使用nodejs的url模块解决地址中的中文乱码问题
- nodejs中循环中套异步+解决async模块
- nodeJs缺少模块问题解决方案
- nodejs的npm安装模块时候报错:npm ERR! Error: CERT_NOT_YET_VALID的解决方法 - 包子博客 _ 关注互联网前端、开发、SEO、移动互联网应用技术
- 关于nodejs模块安装后找不到包解决办法
- nodejs 安装模块失败 解决方法
- nodejs使用npm发布模块带npm报错(verbose stack Error: Invalid name: "")解决
- nodejs文件操作模块FS(File System)常用函数简明总结
- nodejs文件操作模块FS(File System)常用函数简明总结(转)
- nodejs文件操作模块FS(File System)常用函数简明总结
- Nodejs全局安装模块后找不到命令的解决方法
- c# p/invoke 无法加载指定的dll 找不到指定的模块 解决方法
- LINUX驱动学习:加载模块时出现Device or resource busy的解决方法
- nodejs快速入门(三)-模块引入与加载机制
- nodejs-2:模块与包管理工具
- Nodejs中cluster模块的多进程共享数据问题
- 解决binwalk运行提示缺少LZMA模块