Skip to content

Commit

Permalink
error handling added
Browse files Browse the repository at this point in the history
git-svn-id: https://projectname.googlecode.com/svn/trunk@8 c416075f-80b4-e980-4839-00ea3ed24e77
  • Loading branch information
[email protected] committed Mar 21, 2011
1 parent 9ad65eb commit 87d1e30
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 73 deletions.
35 changes: 0 additions & 35 deletions trunk/src/comparer.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions trunk/src/comparer.h

This file was deleted.

21 changes: 7 additions & 14 deletions trunk/src/file_types/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <boost/make_shared.hpp>
#include <cstring>
#include <cassert>
#include <iostream>

#include "base.h"
#include "../kleisli.h"
Expand All @@ -23,21 +24,13 @@ void base::compare(const base& a, category::kleisli::end<compare_result>& cont)
while (true) {
file1.read(buf1, buf_size);
file2.read(buf2, buf_size);
assert(file1.gcount() == file2.gcount());
if (file1.gcount() == file2.gcount()) {
if (memcmp(buf1, buf2, file1.gcount()) != 0) {
return;
}
assert(file1.eof() == file2.eof());
if (file1.eof() && file2.eof()) {
cont.next(compare_result(_path, a._path));
return;
} else
if (!file1.eof() && !file2.eof()) {
continue;
}
if (file1.gcount() != file2.gcount() || file1.eof() != file2.eof() || memcmp(buf1, buf2, file1.gcount()) != 0) {
return;
}
if (file1.eof() && file2.eof()) {
cont.next(compare_result(_path, a._path));
return;
}
return;
}
}

Expand Down
6 changes: 5 additions & 1 deletion trunk/src/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ void recursive::next(const std::string& value) {
struct : category::kleisli::arr<fs::path, fs::path> {
void next(const fs::path& value) { if (is_regular_file(value)) pass(value); }
} filter;
make_pair(recursive_directory_iterator(value), recursive_directory_iterator())
boost::system::error_code e;
make_pair(recursive_directory_iterator(value, e), recursive_directory_iterator())
>>= filter >>= continuation();
if (e) {
logger::std_stream() << value << ": " << e.message() << "\n";
}
} else
if (is_regular_file(value)) {
pass(value);
Expand Down

0 comments on commit 87d1e30

Please sign in to comment.