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.

646 B
Raw Blame
package winfsp

import (
	"strings"

	"github.com/seaweedfs/seaweedfs/weed/util"
)

// relativeToMount rebases a filer path onto the mount root. Metadata events
// cover the whole subscription, so a path outside this mount is not ours to
// report, and a sibling whose name merely starts with the root is not inside
// it either.
func relativeToMount(root, path util.FullPath) (string, bool) {
	full, prefix := string(path), string(root)
	if prefix == "" || prefix == "/" {
		return full, full != ""
	}
	if full == prefix {
		return "/", true
	}
	if !strings.HasPrefix(full, prefix+"/") {
		return "", false
	}
	return full[len(prefix):], true
}