Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Marsaud Smb2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Marsaud Smb2
Commits
ee5074c2
Commit
ee5074c2
authored
Jan 22, 2014
by
Benjamin Chelli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mkdir function in the API
parent
ffecf15e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
0 deletions
+97
-0
README.md
README.md
+11
-0
lib/messages/create-folder.js
lib/messages/create-folder.js
+34
-0
lib/smb2.js
lib/smb2.js
+52
-0
No files found.
README.md
View file @
ee5074c2
...
@@ -87,6 +87,17 @@ smb2Client.writeFile('path\\to\\my\\file.txt', 'Hello Node', function (err) {
...
@@ -87,6 +87,17 @@ smb2Client.writeFile('path\\to\\my\\file.txt', 'Hello Node', function (err) {
});
});
```
```
### smb2Client.mkdir ( path, [mode], callback )
Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. mode defaults to 0777.
Example:
```
javascript
smb2Client
.
mkdir
(
'
path
\\
to
\\
the
\\
folder
'
,
function
(
err
)
{
if
(
err
)
throw
err
;
console
.
log
(
'
Folder created saved!
'
);
});
```
### smb2Client.exists ( path, callback )
### smb2Client.exists ( path, callback )
Test whether or not the given path exists by checking with the file system. Then call the callback argument with either true or false. Example:
Test whether or not the given path exists by checking with the file system. Then call the callback argument with either true or false. Example:
```
javascript
```
javascript
...
...
lib/messages/create-folder.js
0 → 100644
View file @
ee5074c2
var
SMB2Message
=
require
(
'
../message
'
)
,
message
=
require
(
'
../tools/message
'
)
;
module
.
exports
=
message
({
generate
:
function
(
connection
,
params
){
var
buffer
=
new
Buffer
(
params
.
path
,
'
ucs2
'
);
return
new
SMB2Message
({
headers
:{
'
Command
'
:
'
CREATE
'
,
'
SessionId
'
:
connection
.
SessionId
,
'
TreeId
'
:
connection
.
TreeId
}
,
request
:{
'
Buffer
'
:
buffer
,
'
DesiredAccess
'
:
0x001701DF
,
'
FileAttributes
'
:
0x00000000
,
'
ShareAccess
'
:
0x00000000
,
'
CreateDisposition
'
:
0x00000002
,
'
CreateOptions
'
:
0x00000021
,
'
NameOffset
'
:
0x0078
,
'
CreateContextsOffset
'
:
0x007A
+
buffer
.
length
}
});
}
});
lib/smb2.js
View file @
ee5074c2
...
@@ -432,6 +432,58 @@ proto.unlink = function(path, cb){
...
@@ -432,6 +432,58 @@ proto.unlink = function(path, cb){
}
}
/*
* mkdir
* =====
*
* create folder:
*
* - open the file
*
* - remove the file
*
* - close the file
*
*/
proto
.
mkdir
=
function
(
path
,
mode
,
cb
){
if
(
typeof
mode
==
'
function
'
){
cb
=
mode
;
mode
=
'
0777
'
;
}
var
connection
=
this
;
connect
(
connection
,
function
(
err
){
cb
=
scheduleAutoClose
(
connection
,
cb
);
if
(
err
)
cb
(
err
);
else
connection
.
exists
(
path
,
function
(
err
,
exists
){
if
(
err
)
cb
&&
cb
(
err
);
else
if
(
!
exists
){
// SMB2 open file
SMB2Request
(
'
create-folder
'
,
{
path
:
path
},
connection
,
function
(
err
,
file
){
if
(
err
)
cb
&&
cb
(
err
);
// SMB2 query directory
else
SMB2Request
(
'
close
'
,
file
,
connection
,
function
(
err
){
cb
&&
cb
(
null
);
});
});
}
else
{
cb
(
new
Error
(
'
File/Folder already exists
'
));
}
});
});
}
/*
/*
* PRIVATE FUNCTION TO HANDLE CONNECTION
* PRIVATE FUNCTION TO HANDLE CONNECTION
*/
*/
...
...
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