Skip to content

Commit 2c3e5c9

Browse files
committed
Renamed utils
1 parent 3cb55a1 commit 2c3e5c9

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

cmd/cli/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77
"os"
88
"time"
99

10+
mvgoutils "github.com/2024-dissertation/openmvgo/pkg/mvgoutils"
1011
"github.com/2024-dissertation/openmvgo/pkg/openmvg"
1112
"github.com/2024-dissertation/openmvgo/pkg/openmvs"
12-
"github.com/2024-dissertation/openmvgo/pkg/utils"
1313
"github.com/urfave/cli/v3"
1414
)
1515

@@ -52,7 +52,7 @@ func main() {
5252
fmt.Printf("Output Directory: %s\n", outputDir)
5353

5454
// Setup Utils
55-
utils := utils.NewUtils()
55+
utils := mvgoutils.NewMvgoUtils()
5656

5757
timestamp := time.Now().Unix()
5858

pkg/utils/utils.go renamed to pkg/mvgoutils/mvgoutils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package utils
1+
package mvgoutils
22

33
//go:generate mockgen -source=./utils.go -destination=../../mocks/mock_utils.go -package=mocks
4-
type UtilsInterface interface {
4+
type OpenmvgoUtilsInterface interface {
55
Check(e error)
66
RunCommand(name string, args []string) error
77
EnsureDir(path string) error

pkg/utils/utils_impl.go renamed to pkg/mvgoutils/mvgoutils_impl.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package utils
1+
package mvgoutils
22

33
import (
44
"fmt"
@@ -9,21 +9,21 @@ import (
99
"path/filepath"
1010
)
1111

12-
type UtilsImpl struct{}
12+
type MvgoUtilsImpl struct{}
1313

14-
func NewUtils() UtilsInterface {
15-
return &UtilsImpl{}
14+
func NewMvgoUtils() OpenmvgoUtilsInterface {
15+
return &MvgoUtilsImpl{}
1616
}
1717

18-
func (u *UtilsImpl) Check(e error) {
18+
func (u *MvgoUtilsImpl) Check(e error) {
1919
if e != nil {
2020
fmt.Fprintf(os.Stderr, "Error: %v\n", e)
2121
panic(e)
2222
}
2323
}
2424

2525
// RunCommand runs a command with arguments and prints its stdout/stderr in real-time.
26-
func (u *UtilsImpl) RunCommand(name string, args []string) error {
26+
func (u *MvgoUtilsImpl) RunCommand(name string, args []string) error {
2727
cmd := exec.Command(name, args...)
2828
cmd.Stdout = os.Stdout
2929
cmd.Stderr = os.Stderr
@@ -37,7 +37,7 @@ func (u *UtilsImpl) RunCommand(name string, args []string) error {
3737
}
3838

3939
// EnsureDir creates the directory (and parent dirs) if it doesn't exist.
40-
func (u *UtilsImpl) EnsureDir(path string) error {
40+
func (u *MvgoUtilsImpl) EnsureDir(path string) error {
4141
abs, err := filepath.Abs(path)
4242
if err != nil {
4343
return fmt.Errorf("could not resolve absolute path: %w", err)
@@ -53,7 +53,7 @@ func (u *UtilsImpl) EnsureDir(path string) error {
5353
}
5454

5555
// DownloadFile downloads a file from the given URL and saves it to a temporary file.
56-
func (u *UtilsImpl) DownloadFile(url string) (string, error) {
56+
func (u *MvgoUtilsImpl) DownloadFile(url string) (string, error) {
5757
resp, err := http.Get(url)
5858
if err != nil {
5959
return "", fmt.Errorf("failed to download file from %s: %w", url, err)
@@ -80,7 +80,7 @@ func (u *UtilsImpl) DownloadFile(url string) (string, error) {
8080
return out.Name(), nil
8181
}
8282

83-
func (u *UtilsImpl) CopyFile(src, dst string) error {
83+
func (u *MvgoUtilsImpl) CopyFile(src, dst string) error {
8484
fmt.Printf("→ Copying file from %s to %s\n", src, dst)
8585
input, err := os.ReadFile(src)
8686
if err != nil {

pkg/openmvg/openmvg_impl.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"os"
66
"time"
77

8-
"github.com/2024-dissertation/openmvgo/pkg/utils"
8+
"github.com/2024-dissertation/openmvgo/pkg/mvgoutils"
99
)
1010

1111
// Config for running the OpenMVG pipeline
@@ -27,11 +27,14 @@ func NewOpenMVGConfig(inputDir string, outputDir string, cameraDBFile *string) O
2727
}
2828

2929
type AppFileServiceImpl struct {
30-
Utils utils.UtilsInterface
30+
Utils mvgoutils.OpenmvgoUtilsInterface
3131
Config OpenMVGConfig
3232
}
3333

34-
func NewOpenMVGService(config OpenMVGConfig, utils utils.UtilsInterface) AppFileServiceImpl {
34+
func NewOpenMVGService(config OpenMVGConfig, utils mvgoutils.OpenmvgoUtilsInterface) AppFileServiceImpl {
35+
if utils == nil {
36+
utils = mvgoutils.NewMvgoUtils()
37+
}
3538

3639
// Pre run folder checks
3740
if config.InputDir == "" || config.OutputDir == "" {

pkg/openmvs/openmvs_impl.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package openmvs
33
import (
44
"fmt"
55

6-
"github.com/2024-dissertation/openmvgo/pkg/utils"
6+
"github.com/2024-dissertation/openmvgo/pkg/mvgoutils"
77
)
88

99
// Config object
@@ -24,12 +24,16 @@ func NewOpenMVSConfig(outputDir string, buildDir string, maxThreads int) *OpenMV
2424

2525
// OpenMVSService interface implementation
2626
type OpenMVSServiceImpl struct {
27-
Utils utils.UtilsInterface
27+
Utils mvgoutils.OpenmvgoUtilsInterface
2828
Config *OpenMVSConfig
2929
}
3030

3131
// Helper function to create a new OpenMVSServiceImpl
32-
func NewOpenMVSService(config *OpenMVSConfig, utils utils.UtilsInterface) OpenMVSServiceImpl {
32+
func NewOpenMVSService(config *OpenMVSConfig, utils mvgoutils.OpenmvgoUtilsInterface) OpenMVSServiceImpl {
33+
if utils == nil {
34+
utils = mvgoutils.NewMvgoUtils()
35+
}
36+
3337
if config.OutputDir == "" {
3438
utils.Check(fmt.Errorf("input directory must be specified"))
3539
}

0 commit comments

Comments
 (0)