From 666eb460c2e1a308eae221512248b954858d6f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Tue, 22 Sep 2015 20:55:35 +0200 Subject: [PATCH] Use bit operators instead of addition --- src/filesystem.hpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/filesystem.hpp b/src/filesystem.hpp index c8dae31..86b5576 100644 --- a/src/filesystem.hpp +++ b/src/filesystem.hpp @@ -4,16 +4,18 @@ #include #include #include -#include "boost/filesystem.hpp" +#include namespace fs = boost::filesystem; -class filesystem { - static const unsigned DIRS = 1; - static const unsigned FILES = 2; - static const unsigned ALL = 3; - static const unsigned SORTED = 4; +enum filesystem_options { + DIRS = 0x1, + FILES = 0x2, + ALL = DIRS | FILES, + SORTED = ALL | 0x4 +}; +class filesystem { public: bool write(const std::string &path, const std::string &new_content) { @@ -75,17 +77,17 @@ class filesystem { static auto dirs(const std::string &path) { - return filesystem::get_directory_content(path, DIRS + SORTED); + return filesystem::get_directory_content(path, DIRS | SORTED); } static auto files(const std::string &path) { - return filesystem::get_directory_content(path, FILES + SORTED); + return filesystem::get_directory_content(path, FILES | SORTED); } static auto contents(const std::string &path) { - return filesystem::get_directory_content(path, ALL + SORTED); // ALL = DIRS + FILES + return filesystem::get_directory_content(path, ALL | SORTED); // ALL = DIRS | FILES } static auto seperate_contents(const std::string &path)