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

Copying/moving files #160

Open
mystery-z opened this issue Jul 5, 2022 · 5 comments
Open

Copying/moving files #160

mystery-z opened this issue Jul 5, 2022 · 5 comments

Comments

@mystery-z
Copy link

Is there any way to copy/move files using LFS?

I found this from a couple years ago asking for this very feature.

Any updates?
And if not what are the reasons this hasn't been implemented yet?

@mystery-z
Copy link
Author

@hishamhm
Really really sorry for the @ but you seem pretty active here, maybe you could provide a response (if I may humbly ask for this feature).

Thanks!

@Tieske
Copy link
Member

Tieske commented Jul 15, 2022

It can be done in pure Lua I think. That said; if you can contribute a PR, that would be most welcome I think.

@hishamhm
Copy link
Member

@Tieske yes, it can. I have similar pure-Lua code in luarocks.fs.* using lfs. Might even move it out of there and into an lfs/util.lua module here, or something.

@mystery-z
Copy link
Author

@Tieske As far as my research goes, the way to do it in pure lua is to use os.execute, but the problem with that is that Unix and Windows have different commands, so the OS needs to be checked first and then there can be an if...then...elseif... statement to switch depending on the OS.

And for files that can be opened using the io.read can be done by making another file (in the destination directory) and copying over the contents.

Is this something similar to what you mean?

@hishamhm Also could you copy and paste a snippet of your code here? It would really help if I could see how you did this. Thanks!

@hishamhm
Copy link
Member

And for files that can be opened using the io.read can be done by making another file (in the destination directory) and copying over the contents.

Yes, this is what the LuaRocks code does for pure-Lua copying, and os.rename can be used for moving. Using lfs to create folders, there's no need to os.execute.

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

3 participants