Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

behavior detail about attributes() #105

Closed
tst2005 opened this issue Dec 13, 2017 · 2 comments
Closed

behavior detail about attributes() #105

tst2005 opened this issue Dec 13, 2017 · 2 comments

Comments

@tst2005
Copy link
Contributor

tst2005 commented Dec 13, 2017

Hello,

I'm trying to improve a lfs alternative to follow the same API and get the same behavior.

About lfs.attributes()

I see 3 different way to use it.

  1. lfs.attributes(".") returns a table with all fields
  2. lfs.attributes(".", "mode") returns a string : "directory"
  3. lfs.attributes(".", {"mode", "foo", "blksize"}) returns a table with only the requested fields

I'm focused on the last case.

  • If a requested field does not exists (like "foo"), no error raised. it seems legit and ok.

I discovered one special use case...

local lfs = require "lfs"
local request = {"mode", "foo", "blksize"}
local result = lfs.attributes(".", request)
for k,v in pairs(result) do
  print(k,v)
end
1	mode
2	foo
3	blksize
permissions	rwx------
access	1513156646
modification	1513158553
blksize	4096
blocks	123
change	1513158553
size	12345
gid	1000
rdev	0
uid	1000
dev	12345
nlink	123
mode	directory
ino	123456

EDIT: I discovered I missread the documentation, the atable argument is not a list of wanted fields but the result table pointer.

Should we rename the atable argument to resultTable ? and also add this name inside the text ?
I will try to make a PR for this.

@tst2005
Copy link
Contributor Author

tst2005 commented Dec 13, 2017

See #106

@hishamhm
Copy link
Member

PR merged, thank you for contributing to making the documentation clearer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants