(
dir = "/",
opts?: { limit?: number; offset?: number }
)
| 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(); |
no test coverage detected