Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

s3tables: replace custom splitPath with stdlib functions

Chris Lub09d4d5d69ef
diff --git a/weed/s3api/s3tables/utils.go b/weed/s3api/s3tables/utils.go
index a2eacbfe51..b796a1d098 100644
--- a/weed/s3api/s3tables/utils.go
+++ b/weed/s3api/s3tables/utils.go
@@ -2,6 +2,7 @@ package s3tables
import (
"fmt"
+ "path/filepath"
"regexp"
"time"
)
@@ -90,27 +91,9 @@ func generateVersionToken() string {
return fmt.Sprintf("%d", time.Now().UnixNano())
}
-// splitPath splits a path into directory and name components
+// splitPath splits a path into directory and name components using stdlib
func splitPath(path string) (dir, name string) {
- var idx int
- var i int
-
- // Remove trailing slash
- for i = len(path) - 1; i >= 0 && path[i] == '/'; i-- {
- }
- path = path[:i+1]
-
- // Find last separator
- idx = len(path) - 1
- for idx >= 0 && path[idx] != '/' {
- idx--
- }
-
- if idx == -1 {
- return "/", path
- }
- if idx == 0 {
- return "/", path[1:]
- }
- return path[:idx], path[idx+1:]
+ dir = filepath.Dir(path)
+ name = filepath.Base(path)
+ return
}