summaryrefslogtreecommitdiffstats
path: root/application/helpers/filebin_helper.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2014-11-08 17:25:31 +0100
committerFlorian Pritz <bluewind@xinu.at>2014-11-28 14:51:03 +0100
commite60b5468afe0a0d6aa9dab2e6dcf9d186dd168fd (patch)
tree10f8edd85a0758a86f60ee113457766bee322d1d /application/helpers/filebin_helper.php
parenta6655941189e692c4ff06aa41a65e4ac7f0e82fd (diff)
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/helpers/filebin_helper.php')
-rw-r--r--application/helpers/filebin_helper.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php
index e5637ce94..acec213a9 100644
--- a/application/helpers/filebin_helper.php
+++ b/application/helpers/filebin_helper.php
@@ -283,4 +283,31 @@ function cache_function($key, $ttl, $function)
return $content;
}
+function files_are_equal($a, $b)
+{
+ $chunk_size = 8*1024;
+
+ // Check if filesize is different
+ if (filesize($a) !== filesize($b)) {
+ return false;
+ }
+
+ // Check if content is different
+ $ah = fopen($a, 'rb');
+ $bh = fopen($b, 'rb');
+
+ $result = true;
+ while (!feof($ah) && !feof($bh)) {
+ if (fread($ah, $chunk_size) !== fread($bh, $chunk_size)) {
+ $result = false;
+ break;
+ }
+ }
+
+ fclose($ah);
+ fclose($bh);
+
+ return $result;
+}
+
# vim: set noet: