summaryrefslogtreecommitdiffstats
path: root/kioslave/fish/genfishcode.pl
diff options
context:
space:
mode:
authorsamelian <samelian@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-01-23 23:42:11 +0000
committersamelian <samelian@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-01-23 23:42:11 +0000
commitb6fc43ccd522dfbc1e215b12adb8208c156bbd31 (patch)
treeb6d14378dd6c3d2f74ea8acf515cef7f4a024cb2 /kioslave/fish/genfishcode.pl
parentd53bf360906757a36588588fb0286d3b4784ffcb (diff)
downloadtdebase-b6fc43ccd522dfbc1e215b12adb8208c156bbd31.tar.gz
tdebase-b6fc43ccd522dfbc1e215b12adb8208c156bbd31.zip
[kdebase] initial cmake support
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1216551 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kioslave/fish/genfishcode.pl')
-rwxr-xr-xkioslave/fish/genfishcode.pl43
1 files changed, 43 insertions, 0 deletions
diff --git a/kioslave/fish/genfishcode.pl b/kioslave/fish/genfishcode.pl
new file mode 100755
index 000000000..60dfff8de
--- /dev/null
+++ b/kioslave/fish/genfishcode.pl
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use Digest::MD5;
+
+sub md5sum {
+ my $filename = shift;
+ my $digest;
+ eval {
+ open( my $FILE, '<', $filename )
+ or die "Can't find file $filename\n";
+ my $ctx = Digest::MD5->new;
+ $ctx->addfile($FILE);
+ $digest = $ctx->hexdigest;
+ close($FILE);
+ };
+ if ($@) {
+ warn $@;
+ }
+ return $digest;
+}
+
+my $file = $ARGV[0] or die "Missing filename argument";
+
+my $fish_md5 = md5sum($file)
+ or die "Couldn't compute MD5 for some reason\n";
+print qq{#define CHECKSUM "$fish_md5"\n};
+print qq{static const char *fishCode(\n};
+
+open( my $FISH, "<", "$file" ) or die "Can't open $file\n";
+while (<$FISH>) {
+ chomp;
+ s|\\|\\\\|g;
+ s|"|\\"|g;
+ s/^\s*/"/;
+ next if /^"# /;
+ s/\s*$/\\n"/;
+ next if /^"\\n"$/;
+ print "$_\n";
+}
+close($FISH);
+print qq{);\n};