diff --git "a/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/a.txt" "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/a.txt" new file mode 100644 index 0000000000000000000000000000000000000000..59166971672672586337e964bfd74d8d6b61b1cf --- /dev/null +++ "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/a.txt" @@ -0,0 +1 @@ +可以测试option \ No newline at end of file diff --git "a/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/b.txt" "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/b.txt" new file mode 100644 index 0000000000000000000000000000000000000000..b90c5f04b7c6673528accdc628c471ceb1e8b5cb --- /dev/null +++ "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/b.txt" @@ -0,0 +1 @@ +学习简单的不会晕了哦 \ No newline at end of file diff --git "a/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/1.txt" "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/1.txt" new file mode 100644 index 0000000000000000000000000000000000000000..56a6051ca2b02b04ef92d5150c9ef600403cb1de --- /dev/null +++ "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/1.txt" @@ -0,0 +1 @@ +1 \ No newline at end of file diff --git "a/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/2.txt" "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/2.txt" new file mode 100644 index 0000000000000000000000000000000000000000..d8263ee9860594d2806b0dfd1bfd17528b0ba2a4 --- /dev/null +++ "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/2.txt" @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git "a/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/3.txt" "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/3.txt" new file mode 100644 index 0000000000000000000000000000000000000000..e440e5c842586965a7fb77deda2eca68612b1f53 --- /dev/null +++ "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/3.txt" @@ -0,0 +1 @@ +3 \ No newline at end of file diff --git "a/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/4.txt" "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/4.txt" new file mode 100644 index 0000000000000000000000000000000000000000..bf0d87ab1b2b0ec1a11a3973d2845b42413d9767 --- /dev/null +++ "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/demo01/4.txt" @@ -0,0 +1 @@ +4 \ No newline at end of file diff --git "a/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/fs.js" "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/fs.js" new file mode 100644 index 0000000000000000000000000000000000000000..9df57805531440d7973eb440f078631f21c9544c --- /dev/null +++ "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/fs.js" @@ -0,0 +1,26 @@ +let fs = require('fs'); + +fs.open('./index.txt','a',function(err,fd){ + if(err){ + console.log(err); + }else{ + let msg = '今天学习异步文件写入,会有点绕哦!'; + bf = Buffer.from(msg); + fs.write(fd,bf,function(err,writeNum,bf2){ + console.log(err); + console.log(writeNum); + //buffer 转字符串 bf.toString() + console.log(bf2.toString()); + console.log(('done!')); + }); + console.log('写入完成!'); + + //异步文件关闭 + fs.close(fd,function(err){ + console.log('异步文件已关闭'); + console.log(err); + }) + } +}); + +console.log('study node fs async'); \ No newline at end of file diff --git "a/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/fs2.js" "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/fs2.js" new file mode 100644 index 0000000000000000000000000000000000000000..3cf65c215265d76afb58039d9a43c19e38b34113 --- /dev/null +++ "b/\351\251\254\351\235\222\351\235\222/2022-2.25\345\274\202\346\255\245\347\273\203\344\271\240/fs2.js" @@ -0,0 +1,36 @@ +let fs = require('fs'); + +let createFile = { + //创建文件夹 + createPath:function(dir){ + if(fs.existsSync(dir)){ + return ; + } + fs.mkdirSync(dir); + }, + //创建内容 + createContent:function(num){ + return num+''; + }, + + //写入文件 + createFile:function(filePath,content){ + //flags a 可写 + console.log(filePath); + let fd = fs.openSync(filePath,'a'); + fs.writeSync(fd,content); + fs.closeSync(fd); + }, + handle:function(num,dir){ + //目录不存在则创建 + this.createPath(dir); + //循环的创建文件与内容 + for(let i= 1;i