Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
N
node-bigstream
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bs
node-bigstream
Commits
6b01852f
Commit
6b01852f
authored
Jan 30, 2017
by
project
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
ef0a6c51
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
9 deletions
+36
-9
bss_handler.js
storage-service/lib/bss_handler.js
+29
-9
test.js
test/test.js
+7
-0
No files found.
storage-service/lib/bss_handler.js
View file @
6b01852f
var
ctx
=
require
(
'../context'
);
var
fs
=
require
(
'fs'
);
var
ctx
=
require
(
'../../context'
);
var
BinStream
=
ctx
.
getLib
(
'lib/bss/binarystream_v1_1'
);
var
BinStream
=
ctx
.
getLib
(
'lib/bss/binarystream_v1_1'
);
var
path
=
require
(
'path'
);
var
importer
=
require
(
'./importer'
);
var
importer
=
require
(
'./importer'
);
module
.
exports
.
create
=
function
(
prm
)
{
return
new
BSSHandler
(
prm
);
}
function
BSSHandler
(
prm
)
function
BSSHandler
(
prm
)
{
{
if
(
typeof
prm
==
'string'
){
if
(
typeof
prm
==
'string'
){
...
@@ -27,19 +32,36 @@ BSSHandler.prototype.filepath = function()
...
@@ -27,19 +32,36 @@ BSSHandler.prototype.filepath = function()
BSSHandler
.
prototype
.
exists
=
function
()
BSSHandler
.
prototype
.
exists
=
function
()
{
{
var
fp
=
this
.
filepath
();
var
fp
=
this
.
filepath
();
return
path
.
existsSync
(
fp
);
return
fs
.
existsSync
(
fp
);
}
}
BSSHandler
.
prototype
.
open
=
function
(
cb
)
BSSHandler
.
prototype
.
open
=
function
(
cb
)
{
{
var
self
=
this
;
var
self
=
this
;
BinStream
.
open
(
this
.
filepath
,
function
(
err
,
bss
){
if
(
self
.
exists
())
{
open
()
}
else
{
BinStream
.
format
(
self
.
filepath
(),
function
(
err
){
if
(
!
err
){
if
(
!
err
){
self
.
bss
=
bss
;
open
()
}
else
{
cb
(
"format error"
)
}
}
});
}
function
open
(){
BinStream
.
open
(
self
.
filepath
(),
function
(
err
,
bss
){
if
(
!
err
){
self
.
bss
=
bss
;
}
cb
(
err
);
});
}
cb
(
err
);
});
}
}
BSSHandler
.
prototype
.
close
=
function
(
cb
)
BSSHandler
.
prototype
.
close
=
function
(
cb
)
...
@@ -64,8 +86,6 @@ BSSHandler.prototype.cmd = function(cmd,cb)
...
@@ -64,8 +86,6 @@ BSSHandler.prototype.cmd = function(cmd,cb)
BSSHandler
.
prototype
.
cmd_write
=
function
(
prm
,
cb
)
BSSHandler
.
prototype
.
cmd_write
=
function
(
prm
,
cb
)
{
{
if
(
typeof
prm
.
data
)
var
data
=
prm
.
data
;
var
data
=
prm
.
data
;
var
meta
=
prm
.
meta
;
var
meta
=
prm
.
meta
;
...
...
test/test.js
View file @
6b01852f
...
@@ -21,3 +21,10 @@ const crypto = require("crypto");
...
@@ -21,3 +21,10 @@ const crypto = require("crypto");
// const id = crypto.randomBytes(16).toString("hex");
// const id = crypto.randomBytes(16).toString("hex");
//
//
// console.log(id);
// console.log(id);
var
bss_handler
=
ctx
.
getLib
(
'storage-service/lib/bss_handler'
);
var
bss
=
bss_handler
.
create
(
'd:/testfile/hnd.bss'
);
bss
.
open
(
function
(
err
){
console
.
log
(
'open'
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment