2 #include "test-utils.h"
4 #include "dbus/dbus-macros.h"
5 #include "dbus/dbus-sysdeps.h"
7 static void oom (const char *doing) _DBUS_GNUC_NORETURN;
8 static void die (const char *message) _DBUS_GNUC_NORETURN;
11 oom (const char *doing)
13 fprintf (stderr, "*** manual-dir-iter: OOM while %s\n", doing);
18 die (const char *message)
20 fprintf (stderr, "*** manual-dir-iter: %s\n", message);
25 debug (const char *message)
27 fprintf (stdout, "+++ manual-dir-iter: %s\n", message);
40 die ("syntax: manual-dir-iter <path>");
42 dbus_error_init (&tmp_error);
44 if (!_dbus_string_init (&filename))
45 oom ("init filename");
47 if (!_dbus_string_init (&dirname))
50 if (!_dbus_string_append (&dirname, argv[1]))
51 oom ("append argv[1]");
53 dir = _dbus_directory_open (&dirname, &tmp_error);
57 fprintf (stderr, "could not open directory: %s: %s\n",
58 tmp_error.name, tmp_error.message);
62 while (_dbus_directory_get_next_file (dir, &filename, &tmp_error))
65 if (!_dbus_string_init (&full_path))
67 oom ("init full_path");
70 if (!_dbus_string_copy (&dirname, 0, &full_path, 0))
72 oom ("copying full_path to dirname");
75 if (!_dbus_concat_dir_and_file (&full_path, &filename))
77 oom ("concat full_path");
79 debug (_dbus_string_get_const_data (&filename));
80 _dbus_string_free (&full_path);
83 if (dbus_error_is_set (&tmp_error))
84 die (tmp_error.message);
86 _dbus_string_free (&filename);
89 _dbus_directory_close (dir);
91 _dbus_verbose ("*** Test dir name exiting\n");