Skip to content

Commit

Permalink
Use bit operators instead of addition
Browse files Browse the repository at this point in the history
  • Loading branch information
zalox committed Sep 22, 2015
1 parent 69ae02f commit 666eb46
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
#include <vector>
#include <sstream>
#include <fstream>
#include "boost/filesystem.hpp"
#include <boost/filesystem.hpp>

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)
{
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 666eb46

Please sign in to comment.