| 207 | } |
| 208 | |
| 209 | readSync() { |
| 210 | if (this.#closed === true) { |
| 211 | throw new ERR_DIR_CLOSED(); |
| 212 | } |
| 213 | |
| 214 | if (this.#operationQueue !== null) { |
| 215 | throw new ERR_DIR_CONCURRENT_OPERATION(); |
| 216 | } |
| 217 | |
| 218 | if (this.#processHandlerQueue()) { |
| 219 | const dirent = ArrayPrototypeShift(this.#bufferedEntries); |
| 220 | if (this.#options.recursive && dirent.isDirectory()) { |
| 221 | this.#readSyncRecursive(dirent); |
| 222 | } |
| 223 | return dirent; |
| 224 | } |
| 225 | |
| 226 | const result = this.#handle.read( |
| 227 | this.#options.encoding, |
| 228 | this.#options.bufferSize, |
| 229 | ); |
| 230 | |
| 231 | if (result === null) { |
| 232 | return result; |
| 233 | } |
| 234 | |
| 235 | this.#processReadResult(this.#path, result); |
| 236 | |
| 237 | const dirent = ArrayPrototypeShift(this.#bufferedEntries); |
| 238 | if (this.#options.recursive && dirent.isDirectory()) { |
| 239 | this.#readSyncRecursive(dirent); |
| 240 | } |
| 241 | return dirent; |
| 242 | } |
| 243 | |
| 244 | close(callback) { |
| 245 | if (callback === undefined) { |