MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / toContainerFileInfo

Function toContainerFileInfo

agent/app/service/container.go:1598–1615  ·  view source on GitHub ↗
(filePath string, stat container.PathStat, isDir bool)

Source from the content-addressed store, hash-verified

1596}
1597
1598func toContainerFileInfo(filePath string, stat container.PathStat, isDir bool) dto.ContainerFileInfo {
1599 name := stat.Name
1600 if len(name) == 0 {
1601 items := strings.Split(strings.TrimSuffix(filePath, "/"), "/")
1602 name = items[len(items)-1]
1603 }
1604 isLink := stat.Mode&os.ModeSymlink != 0
1605 return dto.ContainerFileInfo{
1606 Name: name,
1607 Path: filePath,
1608 IsDir: isDir,
1609 IsLink: isLink,
1610 LinkTo: stat.LinkTarget,
1611 Size: stat.Size,
1612 Mode: stat.Mode.String(),
1613 ModTime: stat.Mtime.Format(constant.DateTimeLayout),
1614 }
1615}
1616
1617func isContainerDir(cli *client.Client, containerID, targetPath string) (bool, error) {
1618 checkPath := strings.TrimSuffix(targetPath, "/") + "/."

Callers 1

ListContainerFilesMethod · 0.85

Calls 2

StringMethod · 0.45
FormatMethod · 0.45

Tested by

no test coverage detected