From 9aaee6af1441a0037cdcc7e8d218eb393e9adc1d Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Sun, 12 Mar 2017 17:13:07 -0700 Subject: [PATCH] boost fs --- Makefile.am | 2 ++ bootstrap | 2 ++ configure.ac | 6 ++++++ src/Makefile.am | 2 ++ src/cellar.cpp | 28 ++++++++++++++++++++++++++-- 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 bootstrap diff --git a/Makefile.am b/Makefile.am index af437a6..282d9b3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1 +1,3 @@ +ACLOCAL_AMFLAGS = -I m4 +EXTRA_DIST = bootstrap SUBDIRS = src diff --git a/bootstrap b/bootstrap new file mode 100644 index 0000000..c014288 --- /dev/null +++ b/bootstrap @@ -0,0 +1,2 @@ +[ -d m4 ] || mkdir m4 +aclocal -I m4 --install diff --git a/configure.ac b/configure.ac index 18b397d..02b226a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,15 @@ AC_INIT([cellar], [0]) AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects]) +AC_CONFIG_MACRO_DIR([m4]) + AC_PROG_CXX AX_CXX_COMPILE_STDCXX_11 +AX_BOOST_BASE([1.63], , [AC_MSG_ERROR([boost 1.63 required])]) +AX_BOOST_SYSTEM +AX_BOOST_FILESYSTEM + AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([ Makefile diff --git a/src/Makefile.am b/src/Makefile.am index d6adec4..157de51 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,2 +1,4 @@ bin_PROGRAMS = cellar +cellar_CPPFLAGS = $(BOOST_CPPFLAGS) +cellar_LDFLAGS = $(BOOST_LDFLAGS) $(BOOST_SYSTEM_LIB) $(BOOST_FILESYSTEM_LIB) cellar_SOURCES = cellar.cpp diff --git a/src/cellar.cpp b/src/cellar.cpp index a5bc3db..07025a7 100644 --- a/src/cellar.cpp +++ b/src/cellar.cpp @@ -1,4 +1,28 @@ +#include +#include + +#include +#include + +namespace fs = boost::filesystem; + int main(int argc, char* argv[]) { - // stub - return 0; + fs::path cwd(fs::current_path()); + cwd = fs::system_complete("."); + fs::directory_iterator iter_end; + + for (fs::directory_iterator iter_cwd(cwd); iter_cwd != iter_end; ++iter_cwd) { + try { + std::string item = iter_cwd->path().filename().native(); + + std::cout << item; + std::cout << " "; + } + catch (const std::exception& exc) { + std::cout << "fuck" << std::endl; + return 1; + } + } + std::cout << std::endl; + return 0; }