GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add filesystem metadata helpers to hslua-module-system by tionis · Pull Request #161 · hslua/hslua

Conversation

@tionis

@tionis tionis commented May 8, 2026

Copy link
Copy Markdown

This adds two filesystem metadata helpers to hslua-module-system:

  • system.stat(path): returns metadata for a single file or directory.
  • system.ls_with_metadata([directory]): lists directory entries together with metadata.

The metadata table includes:

  • name
  • path
  • type
  • size
  • modification_time
  • access_time
  • permissions
  • is_symlink

This addresses #145 and provides the HsLua-side functionality needed for jgm/pandoc#9422.

Notes

ls remains unchanged, so existing callers keep receiving a plain list of filenames.

Testing

  • cabal test hslua-module-system
  • git diff --check
  • lua -e 'assert(loadfile("hslua-module-system/test/test-system.lua"))'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@tionis
Add filesystem metadata helpers
0f3a977
Copilot AI review requested due to automatic review settings May 8, 2026 22:44
Copilot started reviewing on behalf of tionis May 8, 2026 22:45
View session
Copilot AI reviewed May 8, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends hslua-module-system with filesystem metadata capabilities, adding Lua-facing helpers to stat a single path and to list a directory while returning per-entry metadata (motivated by #145 / pandoc scripting needs).

Changes:

  • Added system.stat(path) to return metadata for a file or directory.
  • Added system.ls_with_metadata([dir]) to list directory entries along with metadata.
  • Updated docs/tests/changelog and bumped hslua-module-system to 1.3.1 (plus new filepath dependency).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
hslua-module-system/src/HsLua/Module/System.hs Implements stat/ls_with_metadata and metadata marshaling helpers.
hslua-module-system/test/test-system.lua Adds test coverage for the new functions and returned metadata shape.
hslua-module-system/README.md Documents the new functions in the module README.
hslua-module-system/hslua-module-system.cabal Bumps version to 1.3.1 and adds filepath dependency.
hslua-module-system/CHANGELOG.md Adds a 1.3.1 entry describing the new API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread hslua-module-system/src/HsLua/Module/System.hs
Comment on lines +671 to +686
isSymlink <- if pathExists
then Directory.pathIsSymbolicLink path
else pure False
isFile <- Directory.doesFileExist path
isDirectory <- Directory.doesDirectoryExist path
let fileType
| isSymlink = "symlink"
| isDirectory = "directory"
| isFile = "file"
| otherwise = "other"
size <- if isFile
then Just <$> Directory.getFileSize path
else pure Nothing
modificationTime <- Directory.getModificationTime path
accessTime <- Directory.getAccessTime path
permissions <- Directory.getPermissions path
Comment thread hslua-module-system/src/HsLua/Module/System.hs
stat :: LuaError e => DocumentedFunction e
stat = defun "stat"
### (\filepath -> ioToLua $
getFileMetadata (FilePath.takeFileName filepath) filepath)
Comment thread hslua-module-system/src/HsLua/Module/System.hs
Comment on lines +427 to +428
, "The returned table contains the path, type, size, permissions,"
, "access time, and modification time."
Comment thread hslua-module-system/README.md
Comment on lines +232 to +243
Obtain metadata for a file or directory. The returned table contains
the path, type, size, permissions, access time, and modification time.

Parameters:

`filepath`
: file or directory path (string)

Returns:

- file metadata (table)

Comment thread hslua-module-system/CHANGELOG.md
Comment on lines +5 to +11
## hslua-module-system-1.3.1

Released pending.

- Added new functions `stat` and `ls_with_metadata`, which return
file metadata such as type, size, permissions, access time, and
modification time.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@tionis
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.