MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / buildStMode

Function buildStMode

packages/kaos/src/ssh.ts:129–145  ·  view source on GitHub ↗

* Build a POSIX st_mode from SFTP Stats. * ssh2's Stats has .mode which already includes both file-type bits and * permission bits, but we also check the boolean helpers as a fallback.

(attrs: SFTPStats)

Source from the content-addressed store, hash-verified

127 * permission bits, but we also check the boolean helpers as a fallback.
128 */
129function buildStMode(attrs: SFTPStats): number {
130 const raw = attrs.mode;
131 // If mode already contains file-type bits, return as-is
132 if ((raw & S_IFMT) !== 0) return raw;
133
134 // Derive file-type bits from the is* helpers
135 let typeBits = 0;
136 if (attrs.isDirectory()) typeBits = S_IFDIR;
137 else if (attrs.isFile()) typeBits = S_IFREG;
138 else if (attrs.isSymbolicLink()) typeBits = S_IFLNK;
139 else if (attrs.isSocket()) typeBits = S_IFSOCK;
140 else if (attrs.isCharacterDevice()) typeBits = S_IFCHR;
141 else if (attrs.isBlockDevice()) typeBits = S_IFBLK;
142 else if (attrs.isFIFO()) typeBits = S_IFIFO;
143
144 return (raw & ~S_IFMT) | typeBits;
145}
146
147function getSftpStatusCode(): typeof DEFAULT_SFTP_STATUS_CODE {
148 return {

Callers 1

statMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected