int ret = 0;
const char *basename;
GError *error = NULL;
- GDir *dir = NULL;
/* Check each file in the path directory, except specific ones */
- dir = g_dir_open(ctf_fs_trace->path.c_str(), 0, &error);
+ const bt2c::GDirUP dir {g_dir_open(ctf_fs_trace->path.c_str(), 0, &error)};
if (!dir) {
BT_CPPLOGE_APPEND_CAUSE_SPEC(ctf_fs_trace->logger,
"Cannot open directory `{}`: {} (code {})", ctf_fs_trace->path,
goto error;
}
- while ((basename = g_dir_read_name(dir))) {
+ while ((basename = g_dir_read_name(dir.get()))) {
if (strcmp(basename, CTF_FS_METADATA_FILENAME) == 0) {
/* Ignore the metadata stream. */
BT_CPPLOGI_SPEC(ctf_fs_trace->logger,
ret = -1;
end:
- if (dir) {
- g_dir_close(dir);
- dir = NULL;
- }
-
if (error) {
g_error_free(error);
}