Hi, I'm trying to make a function for my console-based program (no GUI) that will search a specific folder (depending on user input) and then return all the files-names in that folder to a char array.
How can I solve this problem?
Any help is greatly appreciated,
thanks in advance.
If you don't want to use boost, this problem is platform-dependent, for the listing of a directory content is implementet only as a system call, not in the C library (or any c++ extension).
In Linux you can call a system library function (which internally will set some cpu registers and generate an int 80h if you use an x86 arch), in Windows you have to call another system function which - in some similar way, I would guess, but Windows is not open source, so we can't know for sure - generates a kernel trap and let the file system driver do the work. So, in fact, your question should contain the information what OS you use and go into the corresponding forum.
can some one please point me to boot::filesyetem download.
In the boost home page I cannot see filesystem download.
Do I need to download the entire boost libraries?
If you're using Windows, there's an installer that lets you download only the libraries you need.
Otherwise, I think you'll have to compile the entire source.
... which is the Windows-only-in-this-version-working-system-dependent-ugly-solution. And I have to cope with such code all day long and make it portable. Boost would be the better option here... or, at least, encapsulate the system-dependent stuff in a seperate function/namespace/class/whatever.
Actually what I'm making is a program that will search any specific folder for file duplications and move all files that have the exact same file size to a different folder, where I can manually delete the duplicants. I will use it to sort out all my family pictures :)
I guess to make it portable, you'd have to use the following unix example?
I guess to make it portable, you'd have to use the following unix example?
That would then be portable among POSIX-compatible systems, but still not portable to any OS implementing the libc (you couldn't use it for windows). So if you really *need* system-dependent code, encapsulate it. Otherwise, your code won't be reusable with another system (or the same system in another version). If it is encapsulated and marked properly, porting is a lot easier.