diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | hadori.C | 4 | ||||
-rw-r--r-- | inode.h | 27 |
3 files changed, 3 insertions, 30 deletions
@@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with hadori. If not, see <http://www.gnu.org/licenses/>. -LDFLAGS+=-lz -lboost_program_options +LDFLAGS+=-lboost_program_options CXXFLAGS?=-O2 -Wall CXXFLAGS+=-std=c++0x CPPFLAGS+=-D_FILE_OFFSET_BITS=64 @@ -105,9 +105,6 @@ void handle_file(std::string const & path, struct stat const & s) { if (not config.count("no-time")) if (candidate.stat.st_mtime != s.st_mtime) continue; - if (config.count("hash")) - if (candidate.get_adler() != f.get_adler()) - continue; if (!compare(candidate, f)) continue; verbose << "linking " << candidate << " to " << path << std::endl; @@ -190,7 +187,6 @@ int main (int const argc, char ** argv) { ("help,h", "print this help message") ("version,V", "print version information") ("no-time,t", "ignore mtime") - ("hash", "use adler32 hash to speed up comparing many files with same size and mostly identical content") ("dry-run,n", "don't change anything, implies --verbose") ("verbose,v", "show which files get linked") ("debug,d", "show files being examined") @@ -25,39 +25,16 @@ #include <sys/stat.h> #include <sys/types.h> -#include <zlib.h> - -class inode { -public: +struct inode { std::string const filename; struct stat const stat; -protected: - uLong mutable adler; - -public: inode (std::string const &, struct stat const); - uLong get_adler () const; - friend bool compare (inode const &, inode const &); friend std::ostream& operator<< (std::ostream&, inode const &); }; -inline inode::inode (std::string const & __filename, struct stat const __stat) : filename(__filename), stat(__stat), adler(-1) { -} - -inline uLong inode::get_adler () const { - if (adler == uLong(-1)) { - char buffer[1 << 14]; - std::ifstream f(filename.c_str()); - - adler = adler32(0L, Z_NULL, 0); - while (not f.eof()) { - f.read(buffer, sizeof(buffer)); - adler = adler32(adler, (Bytef *) buffer, f.gcount()); - } - } - return adler; +inline inode::inode (std::string const & __filename, struct stat const __stat) : filename(__filename), stat(__stat) { } inline bool compare (inode const & l, inode const & r) { |