MCPcopy
hub / github.com/wavetermdev/waveterm / ReadAppFile

Function ReadAppFile

pkg/waveappstore/waveappstore.go:289–318  ·  view source on GitHub ↗
(appId string, fileName string)

Source from the content-addressed store, hash-verified

287}
288
289func ReadAppFile(appId string, fileName string) (*FileData, error) {
290 if err := ValidateAppId(appId); err != nil {
291 return nil, fmt.Errorf("invalid appId: %w", err)
292 }
293
294 appDir, err := GetAppDir(appId)
295 if err != nil {
296 return nil, err
297 }
298
299 filePath, err := validateAndResolveFilePath(appDir, fileName)
300 if err != nil {
301 return nil, err
302 }
303
304 fileInfo, err := os.Stat(filePath)
305 if err != nil {
306 return nil, fmt.Errorf("failed to stat file: %w", err)
307 }
308
309 contents, err := os.ReadFile(filePath)
310 if err != nil {
311 return nil, fmt.Errorf("failed to read file: %w", err)
312 }
313
314 return &FileData{
315 Contents: contents,
316 ModTs: fileInfo.ModTime().UnixMilli(),
317 }, nil
318}
319
320func DeleteAppFile(appId string, fileName string) error {
321 if err := ValidateAppId(appId); err != nil {

Callers 2

ReadAppFileCommandMethod · 0.92
generateBuilderAppDataFunction · 0.92

Calls 6

ValidateAppIdFunction · 0.85
GetAppDirFunction · 0.85
StatMethod · 0.80
ReadFileMethod · 0.80
ModTimeMethod · 0.80

Tested by

no test coverage detected