func Init(repo utils.Repository) ([]byte, error) { i, _ := os.Stat(filepath.Clean(".")) err := os.Mkdir(repo.Origin, i.Mode()) if err != nil { return nil, err } if err != nil { return nil, err } output, err := wrapper.Backup(filepath.Clean(repo.Origin), filepath.Clean(repo.BasePath)) if err != nil { return nil, fmt.Errorf("unable to backup", err) } if repo.DirectoryStructure != "" { err = os.Mkdir(repo.DirectoryStructure, i.Mode()) if err != nil { return nil, fmt.Errorf("unable to create directory for directory structure", nil) } } return output, nil }
func AddFile(repo utils.Repository, file string) ([]byte, error) { _, err := os.Create(filepath.Join(repo.Origin, file)) if err != nil { return nil, fmt.Errorf("unable to create file", err) } return wrapper.Backup(filepath.Clean(repo.Origin), filepath.Clean(repo.BasePath)) }
func RemoveDirectory(repo utils.Repository, dir string) ([]byte, error) { err := os.RemoveAll(filepath.Join(repo.Origin, dir)) if err != nil { return nil, fmt.Errorf("unable to remove requested directory", err) } return wrapper.Backup(filepath.Clean(repo.Origin), filepath.Clean(repo.BasePath)) }
func AddDirectory(repo utils.Repository, dir string) ([]byte, error) { i, err := os.Stat(filepath.Clean(repo.BasePath)) if err != nil { return nil, fmt.Errorf("unable to stat working directory", err) } err = os.Mkdir(filepath.Join(repo.Origin, dir), i.Mode()) if err != nil { return nil, fmt.Errorf("unable to make requested directory", err) } return wrapper.Backup(filepath.Clean(repo.Origin), filepath.Clean(repo.BasePath)) }