Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onOPEN(reqID, filename, flags, attrs) {
const localPath = this.getLocalPath(filename);
log.debug('onOPEN', {
'reqID': reqID,
'filename': filename,
'localPath': localPath,
'flags': flags
});
let adapter;
flags = SFTPStream.flagsToString(flags);
log.debug('flags', flags);
switch (flags) {
case 'r':
if (!this.canRead(localPath)) {
return this.sendStatus(reqID, STATUS_CODE.FAILURE);
}
adapter = new FileReader(this, localPath, flags, attrs);
break;
case 'w':
if (!this.canWrite(localPath)) {
return this.sendStatus(reqID, STATUS_CODE.FAILURE);
}
adapter = new FileWriter(this, localPath, flags, attrs);
break;