Skip to content

Commit

Permalink
Merge pull request #78 from IBM/add-options
Browse files Browse the repository at this point in the history
add options for getDataset
  • Loading branch information
tiantn authored Aug 30, 2022
2 parents c59a937 + 2341ea9 commit b90d521
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ connection.listDataset('/u/user1/')
* destDataset - _string_ - Dataset name to used to store the uploaded file, if it starts with `/` this file will be uploaded to USS.
* dataType - _string (default: ascii)_ - Transfer data type, it should be 'ascii' or 'binary', **when transfering 'ascii' files, the end-of-line sequence of input should always be `\r\n`**, otherwise the transfered file will get truncated.
* allocateParams - _object | string_ - A string of space separated DCB attributes or an object of DCB attribute key-value pairs, eg. "LRECL=80 RECFM=VB" or {"LRECL": 80, "RECFM": "VB"}. The tested attributes: BLKsize/BLOCKSize, LRecl, RECfm, PRImary, SECondary, TRacks.
Extra site parameters can also be specified there, for example, 'sbd=(IBM-1047,ISO8859-1)' for encoding setting.

##### Return

Expand Down Expand Up @@ -276,6 +277,7 @@ connection.uploadDataset(input, 'HLQ.HOSTS', "LRECL=80 RECFM=FB")
can be used to download variable-length dataset like V, VB, VBS, etc. The 4-byte RDW (Record Descriptor Word) is inserted at the beginning
of each record.
* stream - _boolean (default: false)_ - `true` if you want to obtain a [ReadableStream](https://nodejs.org/api/stream.html#stream_readable_streams) of the data set content, or `false` to read a full dataset into memory (in Buffer).
* params - _string_ - Add extra site parameters, for example, 'sbd=(IBM-1047,ISO8859-1)' for encoding setting.

##### Return

Expand Down
10 changes: 9 additions & 1 deletion lib/zosAccessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ ZosAccessor.prototype.allocateDataset = function(datasetName, allocateParams) {
* @param {object|string} allocateParams - A string of space separated DCB attributes or an object of DCB attribute key-value pairs.
* eg. "LRECL=80 RECFM=VB" or {"LRECL": 80, "RECFM": "VB"}.
* The tested attributes: BLKsize/BLOCKSize, LRecl, RECfm, PRImary, SECondary, TRacks
* Extra site parameters can also be specified there, for example, 'sbd=(IBM-1047,ISO8859-1)' for encoding setting.
*
*/
ZosAccessor.prototype.uploadDataset = function(input, destDataset, dataType, allocateParams) {
Expand Down Expand Up @@ -211,8 +212,9 @@ ZosAccessor.prototype.uploadDataset = function(input, destDataset, dataType, all
* @param {string} dsn - Dataset name
* @param {string} dataType - 'ascii' or 'binary' or 'ascii_strip_eol' or 'ascii_rdw' or 'binary_rdw'
* @param {boolean} stream - Resolve stream as result or not
* @param {string} params - Add extra site parameters, for example, 'sbd=(IBM-1047,ISO8859-1)' for encoding setting.
*/
ZosAccessor.prototype.getDataset = function (dsn, dataType, stream) {
ZosAccessor.prototype.getDataset = function (dsn, dataType, stream, params) {
var deferred = Q.defer();
var ftpClient = this.client;
dataType = dataType || 'ascii';
Expand All @@ -233,11 +235,17 @@ ZosAccessor.prototype.getDataset = function (dsn, dataType, stream) {
dataType = 'binary';
rdw = 'rdw';
}

var siteParams = [];
siteParams.push('FILETYPE=SEQ');
siteParams.push('TRAILINGBLANKS');
siteParams.push(sbsendeol);
siteParams.push(rdw);

if(params !== undefined && params !== '') {
siteParams.push(params);
}

ftpClient[dataType](function (err) {
if (err) {
return deferred.reject(err);
Expand Down

0 comments on commit b90d521

Please sign in to comment.