MCPcopy Create free account
hub / github.com/MertJSX/folderhost / GetParentPath

Function GetParentPath

utils/get_parent_path.go:5–20  ·  view source on GitHub ↗
(DirectoryItemPath string)

Source from the content-addressed store, hash-verified

3import "strings"
4
5func GetParentPath(DirectoryItemPath string) string {
6 DirectoryItemPath = strings.ReplaceAll(DirectoryItemPath, "\\", "/")
7 lastIndex := strings.LastIndex(DirectoryItemPath, "/")
8
9 if lastIndex == -1 {
10 return DirectoryItemPath
11 }
12
13 item := DirectoryItemPath[0:lastIndex]
14
15 if len(item) > 1 {
16 return item
17 } else {
18 return DirectoryItemPath[0 : lastIndex+1]
19 }
20}

Callers 7

HandleUnzipFunction · 0.92
HandleZipFunction · 0.92
writeFileFunction · 0.92
RenameFunction · 0.92
ReadDirectoryFunction · 0.92
CreateCopyFunction · 0.92
GetDirectoryItemsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected