From b94264b7459c2585425919d6db1d933c5a0a8ab3 Mon Sep 17 00:00:00 2001 From: Al Date: Tue, 1 Dec 2015 11:25:28 -0500 Subject: [PATCH] [parser] Forgot to add shuffle.h/.c --- src/shuffle.c | 24 ++++++++++++++++++++++++ src/shuffle.h | 9 +++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/shuffle.c create mode 100644 src/shuffle.h diff --git a/src/shuffle.c b/src/shuffle.c new file mode 100644 index 00000000..db9979e2 --- /dev/null +++ b/src/shuffle.c @@ -0,0 +1,24 @@ +#include "shuffle.h" + +#include +#include "string_utils.h" + +bool shuffle_file(char *filename) { + char *shuffle_command = NULL; + + #if defined(HAVE_SHUF) + shuffle_command = "shuf"; + #else + return false; + #endif + + char_array *command = char_array_new(); + + char_array_cat_printf(command, "%s -o %s %s", shuffle_command, filename, filename); + + int ret = system(char_array_get_string(command)); + + char_array_destroy(command); + + return ret == EXIT_SUCCESS; +} diff --git a/src/shuffle.h b/src/shuffle.h new file mode 100644 index 00000000..c715d08e --- /dev/null +++ b/src/shuffle.h @@ -0,0 +1,9 @@ +#ifndef HAVE_SHUFFLE_H +#define HAVE_SHUFFLE_H + +#include +#include + +bool shuffle_file(char *filename); + +#endif \ No newline at end of file