Commit ef0a6c51 authored by project's avatar project

--no commit message

--no commit message
parent 56a7ab0f
......@@ -2,15 +2,26 @@ var ctx = require('../context');
var BinStream = ctx.getLib('lib/bss/binarystream_v1_1');
var path = require('path');
var importer = require('./importer');
function BSSHandler(prm)
{
this.repos_dir = prm.repos_dir;
this.name = prm.name;
if(typeof prm == 'string'){
prm = {'file':prm};
}
// this.repos_dir = prm.repos_dir;
// this.name = prm.name;
this.file = prm.file;
}
function name2path(n){
return n.split('.').join('/');
}
BSSHandler.prototype.filepath = function()
{
return this.repos_dir + '/' + name2path(this.name) + '.bss';
//return this.repos_dir + '/' + name2path(this.name) + '.bss';
return this.file;
}
BSSHandler.prototype.exists = function()
......@@ -21,15 +32,48 @@ BSSHandler.prototype.exists = function()
BSSHandler.prototype.open = function(cb)
{
var self = this;
BinStream.open(this.filepath,function(err,bss){
if(!err){
this.bss = bss;
self.bss = bss;
}
cb(err);
});
}
function name2path(n){
return n.split('.').join('/');
BSSHandler.prototype.close = function(cb)
{
this.bss.close(cb);
}
BSSHandler.prototype.cmd = function(cmd,cb)
{
var command = cmd.command;
var param = cmd.param;
switch (command) {
case 'write':
this.cmd_write(param,cb);
break;
default:
cb('invalid cmd');
}
}
BSSHandler.prototype.cmd_write = function(prm,cb)
{
if(typeof prm.data)
var data = prm.data;
var meta = prm.meta;
this.bss.write(data,{'meta':meta},function(err,obj){
if(!err){
cb("write error");
}else {
cb(null);
}
});
}
module.exports.create =function(prm)
{
return new importer(prm)
}
function importer(prm)
{
}
importer.prototype.get_data = function(cb)
{
cb(null,'test');
}
var ctx = require('../context');
var async = require('async');
var BinStream = ctx.getLib('lib/bss/binarystream_v1_1');
var FNAME = "D:/testfile/MyBss.bss";
BinStream.open(FNAME,function(err,bss){
var rd = bss.reader();
var cont = true;
async.whilst(
function() { return cont; },
function(callback) {
rd.nextObject(function(err,obj){
if(!obj){
cont=false;
}else{
//meta = obj.meta;
console.log(obj.data);
}
callback();
});
},function(err){
bss.close(function(err){
console.log('close');
});
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment