Tags: lesiw/fs
Tags
path: Drop always-true protoEnd guards in Split, Clean, and volume All three sites are inside a style.kind == styleURL branch, which only holds when detectStyle found "://" at index > 0. Neither Split nor Clean mutates path in a way that removes "://" beforehand — the local-prefix strip peels ./ or .\, which cannot overlap with :// given that the prefix's second character is a separator, not a colon. volume is called from Rel and segments, both of which pass a detectStyle-classified path directly. strings.Index(path, "://") is always non-negative here; the else arm in Clean is unreachable and the wrapping ifs in Split and volume are dead.
context: Add WithoutWorkDir Clearing the working directory previously had no expression: WithWorkDir composed relative paths, so an empty dir joined onto the existing directory and left it in place. WithoutWorkDir clears it explicitly, like context.WithoutCancel, and WithWorkDir documents the empty dir as a no-op.
buffer: Route init() through Create/Append helpers bufferWriter.init() called CreateFS.Create/AppendFS.Append directly, so CreateBuffer and AppendBuffer skipped the package-level dispatch for trailing-slash tar streaming, path localization, parent directory creation, and the Append read-rewrite fallback.
memfs: implement SymlinkFS and ReadLinkFS Add symlink support to the in-memory filesystem. The node struct gains a target field for storing link destinations. Path resolution follows symlinks in intermediate components and optionally at the final component, with a depth limit of 255 to prevent cycles.
path: add Rel for computing relative paths Rel computes a relative path from basepath to targpath, following the same multi-style approach as Clean and Join. Handles Unix, Windows drive letters, and URL protocol/host volumes with proper comparison and separator detection. Adds segments and volume helpers to support hierarchy comparison and volume extraction.
memfs: implement AbsFS and fix absolute path resolution memfs is inherently rooted but never declared AbsFS. Add Abs() that prepends "/" to resolved paths. Fix resolvePath to skip WorkDir prepending for absolute paths, matching osfs behavior. Without this guard, operations like Stat with absolute paths incorrectly have WorkDir prepended, breaking patterns like find-up that walk the directory tree with absolute paths while WorkDir is set. Thanks to @calvinhtr for finding the resolvePath bug. Apply the same fix to HTTP and S3 filesystem implementations, using lesiw.io/fs/path to detect absolute URL paths. Add FindUp test to fstest that exercises this contract across all filesystem types including URL-based ones.
memfs: implement AbsFS and fix absolute path resolution memfs is inherently rooted but never declared AbsFS. Add Abs() that prepends "/" to resolved paths. Fix resolvePath to skip WorkDir prepending for absolute paths, matching osfs behavior. Without this guard, operations like Stat with absolute paths incorrectly have WorkDir prepended, breaking patterns like find-up that walk the directory tree with absolute paths while WorkDir is set. Thanks to @calvinhtr for finding the resolvePath bug. Apply the same fix to HTTP and S3 filesystem implementations, using lesiw.io/fs/path to detect absolute URL paths. Add FindUp test to fstest that exercises this contract across all filesystem types including URL-based ones.
appendDirAsTar: drain trailing data after tar extraction The pipe fallback in appendDirAsTar closes the reader immediately after extractTarToFS returns. If the tar source has trailing zero-byte padding (e.g. git archive pads to 10KB block boundaries), the unread bytes cause io.ErrClosedPipe on the writer side. Drain remaining pipe data after extraction completes. Also refactor the CreateDir fstest into a table-driven test covering both basic and padded tar streams.
PreviousNext