|
var fs = api.require('fs');
fs.exist({
path: 'fs://file.json'
}, function(ret, err) {
if (ret.exist) {
// 改写.json文件数据
fs.write({
fd: fd,
data: data,
codingType: 'utf8',
offset: 0,
overwrite: true
}, function(ret, err) {
if (ret.status) {
aMap.addLocus({
id: id,
borderWidth: 5,
autoresizing: false,
locusData: "fs://file.json"
});
} else {
}
});
} else {
//失败创建.json文件
fs.createFile({
path: 'fs://file.json'
}, function(ret, err) {
if (ret.status) {
//在改写.json文件数据
fs.write({
fd: fd,
data: data,
codingType: 'utf8',
offset: 0,
overwrite: true
}, function(ret, err) {
if (ret.status) {
aMap.addLocus({
id: id,
borderWidth: 5,
autoresizing: false,
locusData: "fs://file.json"
});
}
});
}
});
}
}); |
|