Skip to content

Commit

Permalink
0501 desktop app
Browse files Browse the repository at this point in the history
  • Loading branch information
lihongmi committed Oct 13, 2017
1 parent 90b383a commit 3cf70dc
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ziliao/
code/0201/node_modules
code/0301/node_modules
code/0301/node_modules
code/0501/electron-quick-start/node_modules
1 change: 1 addition & 0 deletions code/0403/2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworldhelloworld
17 changes: 17 additions & 0 deletions code/0403/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs=require("fs");


var content=fs.readFileSync("./1.txt");
console.log(content.toString());


fs.writeFile("./2.txt","hello",{flag:"a"},(err)=>{
console.log("写入成功");
});

fs.writeFile("./2.txt","world",{flag:"a"},(err)=>{
console.log("写入成功");
});


console.log("读取文件成功");
33 changes: 33 additions & 0 deletions code/0403/app2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const fs=require("fs");

//重命名
/*fs.rename("./1.txt","./11.txt",(err)=>{
if(!err) console.log("重命名成功");
});*/
//判断文件是否存在
var res=fs.existsSync("./2.txt");
console.log(res);

//获取文件基本信息
fs.stat("./2.txt",(err,stats)=>{
if(err){
console.log("获取信息失败");
return false;
}

console.log(stats);

});
//删除文件
if(fs.existsSync("./11.txt")){
fs.unlink("./11.txt");
}

if(!fs.existsSync("./c")){
fs.mkdir("./c");
}


fs.readdir(".",(err,files)=>{
console.log(files);
});
30 changes: 30 additions & 0 deletions code/0403/app3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const path=require("path");
const fs=require("fs");



let lujing="E:\\node_study\\code\\0403\\2.txt";
let lujing1="E:\\node_study\\code\\0403\\";




console.log(path.basename(lujing));
console.log(path.extname(lujing));
console.log(path.dirname(lujing1));

fs.readdir(lujing1,(err,files)=>{
console.log(files);
});

let newlujing=path.join("a","b","c","..","g/f/e/d","..");


console.log(newlujing);

let pathObj=path.parse(lujing);
console.log(pathObj);




8 changes: 8 additions & 0 deletions code/0404/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
在读写文件 或者网络传输 数据
字符串 buffer 二进制数据
*/


12 changes: 12 additions & 0 deletions code/0405/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const events = require('events');


const myEmitter = new events();


myEmitter.on('fangxue', () => {
console.log('吃饭去');
});

myEmitter.emit('fangxue');
myEmitter.emit('fangxue');
6 changes: 6 additions & 0 deletions code/0406/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const path=require("path");

console.log(__dirname);
console.log(__filename);

console.log(path.extname(__filename));
1 change: 1 addition & 0 deletions code/0501/electron-quick-start
Submodule electron-quick-start added at 71199c

0 comments on commit 3cf70dc

Please sign in to comment.