MCPcopy Create free account
hub / github.com/cloudflare/agents / readDir

Method readDir

packages/shell/src/filesystem.ts:1041–1069  ·  view source on GitHub ↗
(
    dir = "/",
    opts?: { limit?: number; offset?: number }
  )

Source from the content-addressed store, hash-verified

1039 // ── Directory operations ───────────────────────────────────────
1040
1041 async readDir(
1042 dir = "/",
1043 opts?: { limit?: number; offset?: number }
1044 ): Promise<FileInfo[]> {
1045 await this.ensureInit();
1046 const normalized = normalizePath(dir);
1047 const limit = opts?.limit ?? 1000;
1048 const offset = opts?.offset ?? 0;
1049 const T = this.tableName;
1050 const rows = await this.sql.query<{
1051 path: string;
1052 name: string;
1053 type: string;
1054 mime_type: string;
1055 size: number;
1056 created_at: number;
1057 modified_at: number;
1058 }>(
1059 `SELECT path, name, type, mime_type, size, created_at, modified_at
1060 FROM ${T}
1061 WHERE parent_path = ?
1062 ORDER BY type ASC, name ASC
1063 LIMIT ? OFFSET ?`,
1064 normalized,
1065 limit,
1066 offset
1067 );
1068 return rows.map(toFileInfo);
1069 }
1070
1071 async glob(pattern: string): Promise<FileInfo[]> {
1072 await this.ensureInit();

Callers 1

cpMethod · 0.95

Calls 2

ensureInitMethod · 0.95
normalizePathFunction · 0.70

Tested by

no test coverage detected