To emulate the behavior of ls -la , you need a combination of readdir and stat . Do man 3 readdir and man 2 stat to get information on how to use them.
Capturing ls -la output is possible, but not such a good idea. People can expect a shell script, but not for C or C ++. This is not even what you need to do in Python or perl if you can help it.
You will need to independently build your structure from the data available to you. strftime can be used to format time in a way that you like.
source share