PDA

View Full Version : [SOLVED] C++ Gather File Information



pcman312
December 13th, 2008, 09:17 AM
I am looking for a way to gather information about a given file/directory using C++ in linux. Essentially, I want to emulate at least some of the functionality of the File object in Java. I'd like to limit the amount of system() calls to a minimum (0 preferred).

Little background: I'm making a file browser and I'd like to be able to get information about a file other than its name.

dwhitney67
December 13th, 2008, 01:42 PM
Read the man-pages on these C library functions:

opendir()
readdir()
closedir()
stat()

geirha
December 13th, 2008, 04:03 PM
To determine the file type you can use libmagic, which is the library the file command uses. Install libmagic-dev (apt:libmagic-dev) and read the manpage libmagic(3).

pcman312
December 16th, 2008, 04:54 AM
Ok, thanks for the help.