+/* Include the specified file path in the backups. Append the path to the
+ * includes list, and to ensure that we actually see the path when scanning the
+ * directory tree, add all the parent directories to the search list, which
+ * means we will scan through the directory listing even if the files
+ * themselves are excluded from being backed up. */
+void add_include(const char *path)
+{
+ printf("Add: %s\n", path);
+ /* Was an absolute path specified? If so, we'll need to start scanning
+ * from the root directory. Make sure that the user was consistent in
+ * providing either all relative paths or all absolute paths. */
+ if (path[0] == '/') {
+ if (includes.size() > 0 && relative_paths == true) {
+ fprintf(stderr,
+ "Error: Cannot mix relative and absolute paths!\n");
+ exit(1);
+ }
+
+ relative_paths = false;
+
+ // Skip over leading '/'
+ path++;
+ } else if (relative_paths == false && path[0] != '/') {
+ fprintf(stderr, "Error: Cannot mix relative and absolute paths!\n");
+ exit(1);
+ }
+
+ includes.push_back(path);
+
+ /* Split the specified path into directory components, and ensure that we
+ * descend into all the directories along the path. */
+ const char *slash = path;
+
+ if (path[0] == '\0')
+ return;
+
+ while ((slash = strchr(slash + 1, '/')) != NULL) {
+ string component(path, slash - path);
+ searches.push_back(component);
+ }
+}
+