MCPcopy Index your code
hub / github.com/Acode-Foundation/Acode / lsDir

Method lsDir

src/fileSystem/sftp.js:63–97  ·  view source on GitHub ↗

* List directory or get file info * @param {String} filename * @param {boolean} stat

(filename = this.#path)

Source from the content-addressed store, hash-verified

61 * @param {boolean} stat
62 */
63 lsDir(filename = this.#path) {
64 return new Promise((resolve, reject) => {
65 sftp.isConnected(async (connectionID) => {
66 (async () => {
67 if (this.#notConnected(connectionID)) {
68 try {
69 await this.connect();
70 } catch (error) {
71 reject(error);
72 return;
73 }
74 }
75
76 const path = this.#safeName(filename);
77
78 sftp.lsDir(
79 path,
80 (res) => {
81 res.forEach((file) => {
82 file.url = Url.join(this.#base, file.url);
83 file.type = mimeType.lookup(filename);
84 if (file.isLink) {
85 file.linkTarget = Url.join(this.#base, file.linkTarget);
86 }
87 });
88 resolve(res);
89 },
90 (err) => {
91 reject(err);
92 },
93 );
94 })();
95 }, reject);
96 });
97 }
98
99 /**
100 *

Callers 14

#copyDirectoryMethod · 0.95
ensureEntryFunction · 0.45
checkPluginsUpdateFunction · 0.45
getAllFilesFunction · 0.45
loadPluginsFunction · 0.45
listFileRecursiveFunction · 0.45
expandListFunction · 0.45
deleteFileFunction · 0.45
deleteRecursivelyFunction · 0.45
moveRecursivelyFunction · 0.45
runFsTestsFunction · 0.45
backupFunction · 0.45

Calls 5

#notConnectedMethod · 0.95
connectMethod · 0.95
#safeNameMethod · 0.95
resolveFunction · 0.85
isConnectedMethod · 0.65

Tested by

no test coverage detected