Clear directories and recursively create directories in Lua

Source: Internet
Author: User

In Lua, LFS. mkdir LFS. rmdir can only be used for a single directory, and LFS. rmdir cannot be used to clear folders.


So I want to use OS .exe cute


Recursive Directory creation is as follows:
OS .exe cute ("mkdir ooxx \ ooxx) -- Windows
OS .exe cute ("mkdir-P ooxx/ooxx) -- UNIX, Linux like


Clear the directory as follows:
OS .exe cute ("del ooxx \) -- Windows
OS .exe cute ("RM-RF ooxx \) -- UNIX, Linux like


The job can be implemented normally, but it is uncomfortable to use OS .exe cute.
If the OS .exe cute statement executed has output, it will interfere with the console, leading to confusion in subsequent output.


To avoid this problem, I had to manually create a directory recursively, clear the directory as a traversal, and then remove them one by one.
I am using Lua LFS to traverse


Although the requirements have been met, I still want to ask if there are any better solutions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.