luafilesystem icon indicating copy to clipboard operation
luafilesystem copied to clipboard

lfs declares a global

Open hishamhm opened this issue 8 years ago • 14 comments

This is considered bad practice nowadays.

On the other hand, fixing this in the code may break a lot of stuff out there (with the trivial fix of changing require("lfs") to local lfs = require("lfs")).

Should we make this change in the code?

hishamhm avatar Feb 28 '16 01:02 hishamhm

yes!

Tieske avatar Feb 28 '16 21:02 Tieske

That would require a change in version. Bump the major to 2.

ignacio avatar Feb 28 '16 21:02 ignacio

agreed

Sent from my iPhone

On 28 de fev de 2016, at 18:49, Ignacio Burgueño [email protected] wrote:

That would require a change in version. Bump the major to 2. — Reply to this email directly or view it on GitHub.

jasonsantos avatar Feb 29 '16 00:02 jasonsantos

@ignacio Oh wow. If we're bumping lfs to 2.0, then we better take the opportunity to make any other API tweaks all at once :)

hishamhm avatar Feb 29 '16 21:02 hishamhm

also something still missing I discussed a long time ago with @stevedonovan is a missing 'filecopy' function. The issue being that this cannot be done in pure Lua on Windows without an ugly dos box popping up. So would be nice to fit that in here as well.

Tieske avatar Mar 01 '16 15:03 Tieske

@Tieske filecopy as in copy file A to file B? can't it be done in pure Lua opening file A for reading and file B for writing and performing reads and writes in 64k blocks? That's what the cp command does in C on Linux at least. I may be missing something (attributes?)

hishamhm avatar Mar 01 '16 18:03 hishamhm

Hello If you speak about API... luafilesystem has most of the features that the other implementation/solution have. Except :

  • a realpath like luaposix has
  • a readlink : an easier/fast way to access to the value of a symlink

Regards,

tst2005 avatar Mar 02 '16 09:03 tst2005

readpath and readlink actually make sense on Windows these days, even though it isn't POSIX.

stevedonovan avatar Mar 02 '16 15:03 stevedonovan

it seems POSIX...

man 2 readlink

CONFORMING TO
       4.4BSD (readlink() first appeared in 4.2BSD), POSIX.1-2001.

man 3 realpath

CONFORMING TO
       4.4BSD, POSIX.1-2001

tst2005 avatar Mar 02 '16 16:03 tst2005

I think @stevedonovan meant that Windows isn't posix.

Tieske avatar Mar 02 '16 17:03 Tieske

filecopy as in copy file A to file B? can't it be done in pure Lua opening file A for reading and file B for writing and performing reads and writes in 64k blocks? That's what the cp command does in C on Linux at least. I may be missing something (attributes?)

Not sure anymore, what it exactly was. But performance is certainly one. @stevedonovan do you recall?

Tieske avatar Mar 02 '16 23:03 Tieske

On Wed, Mar 2, 2016 at 7:18 PM, Thijs Schreijer [email protected] wrote:

I think @stevedonovan https://github.com/stevedonovan meant that Windows isn't posix.

Yes, and also that Windows NTFS supports both hard and soft links, so lfs.readlink can be implemented using the native API. Ditto for realpath.

stevedonovan avatar Mar 03 '16 07:03 stevedonovan

On Thu, Mar 3, 2016 at 1:04 AM, Thijs Schreijer [email protected] wrote:

Not sure anymore, what it exactly was. But performance is certainly one. @stevedonovan https://github.com/stevedonovan do you recall?

Well, even cp does more than just copy - preserves permissions such as executable, etc. And Windows has attributes like read-only, archive, etc.

There's also an API call for copying files ;)

stevedonovan avatar Mar 03 '16 07:03 stevedonovan

Removed th global on 2.0 branch.

mpeterv avatar May 05 '16 12:05 mpeterv