I want to scan a directory tree and list all files and folders inside each directory. I created a program that downloads images from a webcamera and saves them locally. This program creates a filetree based on the time the picture is downloaded. I now want to scan these folders and upload the images to a webserver but I´m not sure how I can scan the directories to find the images.
If anyone could post some sample code it would be very helpful.
edit: I´m running this on an embedded linux system and don´t want to use boost
See
man ftwfor a simple “file tree walk”. I also usedfnmatchin this example.(Not even compile-tested, but you get the idea.)
This is much simpler than dealing with
DIRENTs and recursive traversal yourself.For greater control over traversal, there’s also
fts. In this example, dot-files (files and directories with names starting with “.”) are skipped, unless explicitly passed to the program as a starting point.Again, it’s neither compile-tested nor run-tested, but I thought I’d mention it.