MCPcopy Create free account
hub / github.com/devspace-sh/devspace / createAllFolders

Function createAllFolders

helper/server/tar.go:45–82  ·  view source on GitHub ↗
(name string, perm os.FileMode, options *UpstreamOptions)

Source from the content-addressed store, hash-verified

43}
44
45func createAllFolders(name string, perm os.FileMode, options *UpstreamOptions) error {
46 absPath, err := filepath.Abs(name)
47 if err != nil {
48 return err
49 }
50
51 slashPath := filepath.ToSlash(absPath)
52 pathParts := strings.Split(slashPath, "/")
53 for i := 1; i < len(pathParts); i++ {
54 dirToCreate := strings.Join(pathParts[:i+1], "/")
55 err := os.Mkdir(dirToCreate, perm)
56 if err != nil {
57 if os.IsExist(err) {
58 continue
59 }
60
61 return errors.Errorf("error creating %s: %v", dirToCreate, err)
62 }
63
64 if options.DirCreateCmd != "" {
65 cmdArgs := make([]string, 0, len(options.DirCreateArgs))
66 for _, arg := range options.DirCreateArgs {
67 if arg == "{}" {
68 cmdArgs = append(cmdArgs, dirToCreate)
69 } else {
70 cmdArgs = append(cmdArgs, arg)
71 }
72 }
73
74 out, err := exec.Command(options.DirCreateCmd, cmdArgs...).CombinedOutput()
75 if err != nil {
76 return errors.Errorf("error executing command '%s %s': %s => %v", options.DirCreateCmd, strings.Join(cmdArgs, " "), string(out), err)
77 }
78 }
79 }
80
81 return nil
82}
83
84func untarNext(tarReader *tar.Reader, options *UpstreamOptions) (bool, error) {
85 header, err := tarReader.Next()

Callers 1

untarNextFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected