27 lines
468 B
Go
27 lines
468 B
Go
|
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
||
|
|
||
|
package ext
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
)
|
||
|
|
||
|
type FilePath string
|
||
|
|
||
|
func (f *FilePath) Exists() bool {
|
||
|
_, err := os.Stat(string(*f))
|
||
|
return !os.IsNotExist(err)
|
||
|
}
|
||
|
|
||
|
func (f *FilePath) Add(relative string) {
|
||
|
newPath := filepath.Join(string(*f), relative)
|
||
|
*f = FilePath(newPath)
|
||
|
}
|
||
|
|
||
|
|
||
|
func (f FilePath) Abs() FilePath {
|
||
|
result, _ := filepath.Abs(string(f))
|
||
|
return FilePath(result)
|
||
|
}
|