Skip to content

Implement SEEK whence support (SEEK_SET, SEEK_CUR, SEEK_END)#195

Merged
toddr merged 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/implement-seek-whence
Feb 12, 2026
Merged

Implement SEEK whence support (SEEK_SET, SEEK_CUR, SEEK_END)#195
toddr merged 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/implement-seek-whence

Conversation

@Koan-Bot
Copy link
Contributor

Summary

The SEEK tied filehandle method previously died with "Unimplemented" for any $whence value other than 0. This implements full whence support:

  • SEEK_SET (0): seek to absolute position from start
  • SEEK_CUR (1): seek relative to current position
  • SEEK_END (2): seek relative to end of file

Returns the new position on success (or "0 but true" for position 0), and 0 on failure (out of bounds). Invalid whence values die.

Fixes #77

Changes

  • lib/Test/MockFile/FileHandle.pm: Replace stub SEEK with full whence implementation
  • t/seek.t: New comprehensive test file (30+ tests) covering all whence modes, edge cases (empty files, seek after write, invalid whence), and both seek() and sysseek() builtins
  • t/sysopen.t: Extended with parallel real/mock sysseek tests for SEEK_CUR and SEEK_END

Test plan

  • CI passes across Perl 5.14-5.42
  • t/seek.t exercises all three whence modes
  • t/sysopen.t verifies mock behavior matches real filehandle behavior

🤖 Generated with Claude Code

@toddr
Copy link
Member

toddr commented Feb 11, 2026

Please re-base

The SEEK tied filehandle method previously died with "Unimplemented"
for any whence value other than 0 (SEEK_SET). This implements full
whence support:

- SEEK_SET (0): seek to absolute position
- SEEK_CUR (1): seek relative to current position
- SEEK_END (2): seek relative to end of file

Returns the new position on success (or "0 but true" for position 0),
and 0 on failure (out of bounds). Invalid whence values die.

Adds comprehensive tests in t/seek.t covering all whence modes, edge
cases (empty files, seek after write, invalid whence), and extends
t/sysopen.t with parallel real/mock sysseek tests.

Fixes cpanel#77

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Koan-Bot
Copy link
Contributor Author

Rebase: Implement SEEK whence support (SEEK_SET, SEEK_CUR, SEEK_END)

Branch koan.atoomic/implement-seek-whence has been rebased onto master and force-pushed.

Actions

  • Read PR comments and review feedback
  • Rebased koan.atoomic/implement-seek-whence onto origin/master
  • Force-pushed koan.atoomic/implement-seek-whence

Automated by Kōan

@Koan-Bot Koan-Bot force-pushed the koan.atoomic/implement-seek-whence branch from f31ba77 to ecd1dcf Compare February 11, 2026 19:00
@atoomic atoomic marked this pull request as ready for review February 11, 2026 22:54
@toddr toddr merged commit 7d115e8 into cpanel:master Feb 12, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

seek / truncate / tell are not supported

3 participants