tests/utils/utils.sh: use `+=` instead of expanding the same variable
[babeltrace.git] / tests / utils / common.c
... / ...
CommitLineData
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 *
4 * Copyright (C) 2012 Yannick Brosseau <yannick.brosseau@gmail.com>
5 *
6 * Lib BabelTrace - Common function to all tests
7 */
8
9#include "common.h"
10
11#include <unistd.h>
12#include <stdio.h>
13#include <dirent.h>
14#include <ftw.h>
15
16#define RMDIR_NFDOPEN 8
17
18static
19int nftw_recursive_rmdir(const char *file,
20 const struct stat *sb __attribute__((unused)),
21 int flag,
22 struct FTW *s __attribute__((unused)))
23{
24 switch (flag) {
25 case FTW_F:
26 unlink(file);
27 break;
28 case FTW_DP:
29 rmdir(file);
30 break;
31 }
32
33 return 0;
34}
35
36void recursive_rmdir(const char *path)
37{
38 int nftw_flags = FTW_PHYS | FTW_DEPTH;
39
40 nftw(path, nftw_recursive_rmdir, RMDIR_NFDOPEN, nftw_flags);
41}
This page took 0.022868 seconds and 4 git commands to generate.