MCPcopy Create free account
hub / github.com/mscdex/ssh2 / stat

Method stat

lib/protocol/SFTP.js:982–1008  ·  view source on GitHub ↗
(path, cb)

Source from the content-addressed store, hash-verified

980 );
981 }
982 stat(path, cb) {
983 if (this.server)
984 throw new Error('Client-only method called in server mode');
985
986 /*
987 uint32 id
988 string path
989 */
990 const pathLen = Buffer.byteLength(path);
991 let p = 9;
992 const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
993
994 writeUInt32BE(buf, buf.length - 4, 0);
995 buf[4] = REQUEST.STAT;
996 const reqid = this._writeReqid = (this._writeReqid + 1) & MAX_REQID;
997 writeUInt32BE(buf, reqid, 5);
998
999 writeUInt32BE(buf, pathLen, p);
1000 buf.utf8Write(path, p += 4, pathLen);
1001
1002 this._requests[reqid] = { cb };
1003
1004 const isBuffered = sendOrBuffer(this, buf);
1005 this._debug && this._debug(
1006 `SFTP: Outbound: ${isBuffered ? 'Buffered' : 'Sending'} STAT`
1007 );
1008 }
1009 lstat(path, cb) {
1010 if (this.server)
1011 throw new Error('Client-only method called in server mode');

Callers 4

tryStatMethod · 0.95
existsMethod · 0.95
tryStatFunction · 0.80
test-sftp.jsFile · 0.80

Calls 2

writeUInt32BEFunction · 0.85
sendOrBufferFunction · 0.85

Tested by

no test coverage detected