aboutsummaryrefslogtreecommitdiff
path: root/hotline/file_wrapper.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2022-06-20 22:21:28 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2022-06-20 22:21:28 -0700
commitf22acf38da970aa0d865a9978c9499dad01d235f (patch)
tree6811766749c794afd9eb23e372cc1673f1bae41a /hotline/file_wrapper.go
parent7cd900d61edbd6d322db3cecb913adf574389320 (diff)
Convert hardcoded path separators to filepath.Join
Diffstat (limited to 'hotline/file_wrapper.go')
-rw-r--r--hotline/file_wrapper.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/hotline/file_wrapper.go b/hotline/file_wrapper.go
index 3773e79..2ad76f4 100644
--- a/hotline/file_wrapper.go
+++ b/hotline/file_wrapper.go
@@ -8,13 +8,13 @@ import (
"io/fs"
"os"
"path"
- "strings"
+ "path/filepath"
)
const (
incompleteFileSuffix = ".incomplete"
- infoForkNameTemplate = "%s.info_%s" // template string for info fork filenames
- rsrcForkNameTemplate = "%s.rsrc_%s" // template string for resource fork filenames
+ infoForkNameTemplate = ".info_%s" // template string for info fork filenames
+ rsrcForkNameTemplate = ".rsrc_%s" // template string for resource fork filenames
)
// fileWrapper encapsulates the data, info, and resource forks of a Hotline file and provides methods to manage the files.
@@ -33,18 +33,17 @@ type fileWrapper struct {
}
func newFileWrapper(fs FileStore, path string, dataOffset int64) (*fileWrapper, error) {
- pathSegs := strings.Split(path, pathSeparator)
- dir := strings.Join(pathSegs[:len(pathSegs)-1], pathSeparator)
- fName := pathSegs[len(pathSegs)-1]
+ dir := filepath.Dir(path)
+ fName := filepath.Base(path)
f := fileWrapper{
fs: fs,
name: fName,
path: dir,
dataPath: path,
dataOffset: dataOffset,
- rsrcPath: fmt.Sprintf(rsrcForkNameTemplate, dir+"/", fName),
- infoPath: fmt.Sprintf(infoForkNameTemplate, dir+"/", fName),
- incompletePath: dir + "/" + fName + incompleteFileSuffix,
+ rsrcPath: filepath.Join(dir, fmt.Sprintf(rsrcForkNameTemplate, fName)),
+ infoPath: filepath.Join(dir, fmt.Sprintf(infoForkNameTemplate, fName)),
+ incompletePath: filepath.Join(dir, fName+incompleteFileSuffix),
ffo: &flattenedFileObject{},
}
@@ -100,11 +99,11 @@ func (f *fileWrapper) incompleteDataName() string {
}
func (f *fileWrapper) rsrcForkName() string {
- return fmt.Sprintf(rsrcForkNameTemplate, "", f.name)
+ return fmt.Sprintf(rsrcForkNameTemplate, f.name)
}
func (f *fileWrapper) infoForkName() string {
- return fmt.Sprintf(infoForkNameTemplate, "", f.name)
+ return fmt.Sprintf(infoForkNameTemplate, f.name)
}
func (f *fileWrapper) creatorCode() []byte {