Talk:RAF: Riot Archive File

RAF Extraction in BASH (with coreutils and gzip)
First parameter is the path to the .raf file, the second paramater is optional and is the path to dump all the decompressed files, and the third parameter is optional and is the path to the raf.dat file if it's not in the same directory or does not share the same name as the .raf file.

I'll port this to POSIX shell eventually. readbin { dd if="$1" bs=1 skip=$2 count=$3 2> /dev/null } raf="$1" # ends with .raf outdir="${2-.}" rafdat="${3-$1.dat}" t=$(readbin "$raf" 12 8 | xxd -p) flistoffset=$((0x${t:6:2}${t:4:2}${t:2:2}${t:0:2})) plistoffset=$((0x${t:14:2}${t:12:2}${t:10:2}${t:8:2})) t=$(readbin "$raf" $flistoffset 4 | xxd -p) flistcount=$((0x${t:6:2}${t:4:2}${t:2:2}${t:0:2})) flist=$(readbin "$raf" $[flistoffset+4] $[flistcount*16] | xxd -p -c $[flistcount*16]) t=$(readbin "$raf" $plistoffset 8 | xxd -p) plistsize=$((0x${t:6:2}${t:4:2}${t:2:2}${t:0:2})) plistcount=$((0x${t:14:2}${t:12:2}${t:10:2}${t:8:2})) plist=$(readbin "$raf" $[plistoffset+8] $[plistcount*8] | xxd -p -c $[plistcount*8]) po=$[(plistcount*8)+8] paths=$(readbin "$raf" $[plistoffset+po] $plistsize | xxd -p -c $plistsize) for i in $(seq 0 $[flistcount-1]); do  t=${flist:$[i*32]:32} file_offset=$((0x${t:14:2}${t:12:2}${t:10:2}${t:8:2})) file_size=$((0x${t:22:2}${t:20:2}${t:18:2}${t:16:2})) t=${plist:$[$((0x${t:30:2}${t:28:2}${t:26:2}${t:24:2}))*16]:16} file_path=$(echo ${paths:$[($((0x${t:6:2}${t:4:2}${t:2:2}${t:0:2}))-po)*2]:$[($((0x${t:14:2}${t:12:2}${t:10:2}${t:8:2}))-1)*2]} | xxd -r -p) echo $file_path outfile="$outdir/$file_path" mkdir -p "$(dirname "$outfile")" cat <(printf "\x1f\x8b\x08\x00\x00\x00\x00\x00") <(dd if="$rafdat" bs=1 skip=$file_offset count=$file_size 2> /dev/null) | gzip -dc > "$outfile" 2> /dev/null done Higgs1 (talk) 16:27, June 7, 2013 (UTC)
 * 1) !/bin/bash