Move to kernel style SPDX license identifiers
[babeltrace.git] / tests / utils / common.c
CommitLineData
aa968dde 1/*
0235b0db 2 * SPDX-License-Identifier: GPL-2.0-only
aa968dde 3 *
0235b0db 4 * Copyright (C) 2012 Yannick Brosseau <yannick.brosseau@gmail.com>
aa968dde 5 *
0235b0db 6 * Lib BabelTrace - Common function to all tests
aa968dde 7 */
aa968dde 8
7c7301d5
SM
9#include "common.h"
10
0aeee125
PP
11#include <unistd.h>
12#include <stdio.h>
ebd04048 13#include <dirent.h>
e1f4c4f7 14#include <ftw.h>
aa968dde 15
e1f4c4f7 16#define RMDIR_NFDOPEN 8
851299b9 17
e1f4c4f7
MJ
18static
19int nftw_recursive_rmdir(const char *file, const struct stat *sb, int flag,
20 struct FTW *s)
21{
22 switch (flag) {
23 case FTW_F:
24 unlink(file);
25 break;
26 case FTW_DP:
27 rmdir(file);
28 break;
851299b9
JG
29 }
30
e1f4c4f7
MJ
31 return 0;
32}
851299b9 33
e1f4c4f7
MJ
34void recursive_rmdir(const char *path)
35{
36 int nftw_flags = FTW_PHYS | FTW_DEPTH;
851299b9 37
e1f4c4f7 38 nftw(path, nftw_recursive_rmdir, RMDIR_NFDOPEN, nftw_flags);
851299b9 39}
This page took 0.06702 seconds and 4 git commands to generate.