MCPcopy Create free account
hub / github.com/breck7/scroll / _read

Method _read

external/.scrollLibs.js:21691–21725  ·  view source on GitHub ↗
(absolutePath)

Source from the content-addressed store, hash-verified

21689 this.fileCache = {}
21690 }
21691 async _read(absolutePath) {
21692 if (isUrl(absolutePath)) {
21693 const result = await fetchWithCache(absolutePath)
21694 return {
21695 absolutePath,
21696 exists: result.exists,
21697 content: result.content,
21698 stats: { mtimeMs: Date.now(), ctimeMs: Date.now() }
21699 }
21700 }
21701 const { fileCache } = this
21702 if (fileCache[absolutePath]) return fileCache[absolutePath]
21703 try {
21704 const stats = await fsp.stat(absolutePath)
21705 const content = await fsp.readFile(absolutePath, {
21706 encoding: "utf8",
21707 flag: "r" // explicit read flag
21708 })
21709 const normalizedContent = content.includes("\r") ? content.replace(/\r/g, "") : content
21710 fileCache[absolutePath] = {
21711 absolutePath,
21712 exists: true,
21713 content: normalizedContent,
21714 stats
21715 }
21716 } catch (error) {
21717 fileCache[absolutePath] = {
21718 absolutePath,
21719 exists: false,
21720 content: "",
21721 stats: { mtimeMs: 0, ctimeMs: 0 }
21722 }
21723 }
21724 return fileCache[absolutePath]
21725 }
21726 async exists(absolutePath) {
21727 if (isUrl(absolutePath)) {
21728 const result = await fetchWithCache(absolutePath)

Callers 4

existsMethod · 0.95
readMethod · 0.95
getMTimeMethod · 0.95
getCTimeMethod · 0.95

Calls 3

isUrlFunction · 0.85
fetchWithCacheFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected