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
70513a34
Commit
70513a34
authored
Dec 03, 2018
by
Julien Fontanet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(writeFile): support flags
`flag` option is also supported for `fs` compatibility
parent
f30bfccc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
lib/api/writeFile.js
lib/api/writeFile.js
+23
-7
No files found.
lib/api/writeFile.js
View file @
70513a34
var
SMB2Forge
=
require
(
'
../tools/smb2-forge
'
);
var
SMB2Request
=
SMB2Forge
.
request
;
var
BigInt
=
require
(
'
../tools/bigint
'
);
var
constants
=
require
(
'
../structures/constants
'
);
/*
* writeFile
...
...
@@ -23,6 +24,16 @@ module.exports = function writeFile(filename, data, options, cb) {
options
=
{};
}
var
createDisposition
;
var
flags
=
options
!=
null
&&
(
options
.
flags
||
options
.
flag
);
if
(
flags
===
'
r+
'
)
{
createDisposition
=
constants
.
FILE_OPEN
;
}
else
if
(
flags
===
'
w
'
||
flags
===
'
w+
'
)
{
createDisposition
=
constants
.
FILE_OVERWRITE_IF
;
}
else
if
(
flags
===
'
wx
'
||
flags
===
'
wx+
'
)
{
createDisposition
=
constants
.
FILE_CREATE
;
}
options
.
encoding
=
options
.
encoding
||
'
utf8
'
;
var
connection
=
this
;
...
...
@@ -33,14 +44,19 @@ module.exports = function writeFile(filename, data, options, cb) {
var
fileLength
=
new
BigInt
(
8
,
fileContent
.
length
);
function
createFile
(
fileCreated
)
{
SMB2Request
(
'
create
'
,
{
path
:
filename
},
connection
,
function
(
err
,
f
)
{
SMB2Request
(
'
create
'
,
{
createDisposition
:
createDisposition
,
path
:
filename
},
connection
,
function
(
err
,
f
)
{
if
(
err
)
cb
&&
cb
(
err
);
// SMB2 set file size
else
{
file
=
f
;
fileCreated
();
}
});
}
);
}
function
closeFile
(
fileClosed
)
{
...
...
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