From 9a6177092f93bfd8dd97fa915b5064a3b273c005 Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Sun, 12 Mar 2017 22:32:46 -0700 Subject: [PATCH] move listdir to separate file --- src/fs.cpp | 29 +++++++++++++++++++++++++++++ src/fs.hpp | 16 ++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/fs.cpp create mode 100644 src/fs.hpp diff --git a/src/fs.cpp b/src/fs.cpp new file mode 100644 index 0000000..a8aeae3 --- /dev/null +++ b/src/fs.cpp @@ -0,0 +1,29 @@ +#include +#include +#include + +#include +#include + +#include "fs.hpp" + +using namespace std; + +vector cellar::fs::listdir(string path) { + vector result; + boost::filesystem::path cwd(path); + boost::filesystem::directory_iterator iter_end; + + for (boost::filesystem::directory_iterator iter_cwd(cwd); iter_cwd != iter_end; ++iter_cwd) { + try { + string item = iter_cwd->path().filename().native(); + + result.push_back(item); + } + catch (const exception& exc) { + cout << "fuck" << endl; + } + } + return result; +} + diff --git a/src/fs.hpp b/src/fs.hpp new file mode 100644 index 0000000..fdb618e --- /dev/null +++ b/src/fs.hpp @@ -0,0 +1,16 @@ +#ifndef __FS_HPP +#define __FS_HPP +#pragma once + +#include +#include + +using namespace std; + +namespace cellar { + namespace fs { + extern vector listdir(string path); + } +} + +#endif // __FS_HPP