MCPcopy Create free account
hub / github.com/microsoft/typescript-go / GetFileByPath

Method GetFileByPath

internal/project/snapshotfs.go:89–104  ·  view source on GitHub ↗
(fileName string, path tspath.Path)

Source from the content-addressed store, hash-verified

87}
88
89func (s *SnapshotFS) GetFileByPath(fileName string, path tspath.Path) FileHandle {
90 if file, ok := s.overlays[path]; ok {
91 return file
92 }
93 if file, ok := s.diskFiles[path]; ok {
94 return file
95 }
96 newEntry := memoizedDiskFile(sync.OnceValue(func() FileHandle {
97 if contents, ok := s.fs.ReadFile(fileName); ok {
98 return newDiskFile(fileName, contents)
99 }
100 return nil
101 }))
102 entry, _ := s.readFiles.LoadOrStore(path, newEntry)
103 return entry()
104}
105
106func (s *SnapshotFS) GetAccessibleEntries(directoryName string) vfs.Entries {
107 var entries vfs.Entries

Callers 2

TestSnapshotFSFunction · 0.95
GetFileMethod · 0.95

Calls 5

memoizedDiskFileFuncType · 0.85
newDiskFileFunction · 0.85
entryStruct · 0.85
ReadFileMethod · 0.65
LoadOrStoreMethod · 0.45

Tested by 1

TestSnapshotFSFunction · 0.76