Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 163911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:39:02+00:00 2026-05-11T11:39:02+00:00

Like the title says; how do I load every file in a directory? I’m

  • 0

Like the title says; how do I load every file in a directory? I’m interested in both c++ and lua.

Edit: For windows I’d be glad for some real working code and especially for lua. I can do with boost::filesystem for c++.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T11:39:02+00:00Added an answer on May 11, 2026 at 11:39 am

    For Lua, you want the module Lua Filesystem.

    As observed by Nick, accessing the file system itself (as opposed to individual files) is outside the scope of the C and C++ standards. Since Lua itself is (with the exception of the dynamic loader used to implement require() for C modules) written in standard C, the core language lacks many file system features.

    However, it is easy to extend the Lua core since (nearly) any platform that has a file system also supports DLLs or shared libraries. Lua File system is a portable library that adds support for directory iteration, file attribute discovery, and the like.

    With lfs, emulating some of the capability of DIR in Lua is essentially as simple as:

    require 'lfs' dot = arg[1] or '.' for name in lfs.dir(dot) do     local fqn = dot..'/'..name     local attr = lfs.attributes(fqn)     print(name, attr.mode, os.date('%Y-%m-%d %H:%M',attr.modification), attr.size) end 

    Which produces output that looks like:

    E:...>t-lfs.lua .       directory       2009-04-02 13:23        0 ..      directory       2009-04-02 13:18        0 foo.txt file    2009-02-23 01:56        0 t-lfs.lua       file    2009-04-02 13:18        241  E:...> 

    If your copy of Lua came from Lua for Windows, then you already have lfs installed, and the above sample will work out of the box.

    Edit: Incidentally, the Lua solution might also be a sensible C or C++ solution. The Lua core is not at all large, provides a dynamic, garbage-collected language, and is easy to interact with from C either as a hosting application or as an extension module. To use lfs from a C application, you would link with the Lua DLL, initialize a Lua state, and get the state to execute the require'lfs' either via luaL_dostring() or by using the C API to retrieve the require() function from the global table, push the string 'lfs', and call the Lua function with something like lua_pcall(L,1,1,0), which leaves the lfs table on the top of the Lua stack.

    This approach probably makes the most sense if you already had a need for an embedded scripting language, and Lua meets your requirements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Microsoft finally posted a knowledge base article about this issue.… May 11, 2026 at 4:29 pm
  • Editorial Team
    Editorial Team added an answer Most testing frameworks now support some sort of data based… May 11, 2026 at 4:29 pm
  • Editorial Team
    Editorial Team added an answer You said you used WinMerge - well it has the… May 11, 2026 at 4:29 pm

Related Questions

Like the title says; how do I load every file in a directory? I'm
Like the title says, the error I get is the following: An invalid '/'
The title pretty much says it all. When I'm doing some reflection through my
I want to convert function object to function. I wrote this code, but it
Well, as the title says, how can I set an image or anything else

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.