| 165 | } |
| 166 | |
| 167 | func (u *Unarchiver) createAllFolders(name string, perm os.FileMode) error { |
| 168 | absPath, err := filepath.Abs(name) |
| 169 | if err != nil { |
| 170 | return err |
| 171 | } |
| 172 | |
| 173 | slashPath := filepath.ToSlash(absPath) |
| 174 | pathParts := strings.Split(slashPath, "/") |
| 175 | for i := 1; i < len(pathParts); i++ { |
| 176 | dirToCreate := strings.Join(pathParts[:i+1], "/") |
| 177 | err := os.Mkdir(dirToCreate, perm) |
| 178 | if err != nil { |
| 179 | if os.IsExist(err) { |
| 180 | continue |
| 181 | } |
| 182 | |
| 183 | return errors.Errorf("Error creating %s: %v", dirToCreate, err) |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | return nil |
| 188 | } |
| 189 | |
| 190 | // Archiver is responsible for compressing specific files and folders within a target directory |
| 191 | type Archiver struct { |