Reflex — File Browser
Reflexv0.1 / Reflexv0.1 / Reflex / system / scripts / mcodec.mrc
mcodec.mrc — 3.52 KB — Download this file
;=========================================================================
; mIRC Addon Compressor/Decompressor
; Version: 0.1
;
; By: cypher
; E-mail: allenhunt@gmail.com
; Website: http://cypher.xtmembers.com
; IRC: irc.extremeirc.org : #extremeteam
;
;=========================================================================
;
; /mpack <packname> [compression_level] <file1> [file2] ... [file2]
;
; compresses all FILES into one OUTPUTFILE. The COMPRESSION_LEVEL is a
; value between 1-6 where 6 is the most compressed and 1 is the least. The
; default COMPRESSION_LEVEL is 6.
;
;
; /munpack [-bl] <file>
;
; decompresses all files in FILE and exports them to their place defined
; by how they were packed. this can only be in a directory that has the
; mircexe in one of its parent directories. if the file already exists it
; will replace it. files with an extension .mrcl will be loaded.
;
; -b will cause any existing file to be renamed FILE.bak
; -l causes the files extracted to be logged to $mpacklog
;
;=========================================================================
alias mpackdir { return $shortfn($mircdir) }
alias mpacklog { return $datdir $+ mpacklog.dat }
alias mpack {
var %f = $+($remove($1,.mpk),.mpk) , %c = 6
if ($2 isnum) { %c = $2 | tokenize 32 $3- }
else { tokenize 32 $2- }
if ($fopen(mpack)) { .fclose mpack }
.fopen -o mpack $mpackdir $+ %f
mpack_add %f %c $*
.fclose mpack*
echo -qcs info %f mpack file made.
}
alias mpack_add {
if ($exists($3-)) {
if ($fopen(mpackfile)) { .fclose mpackfile }
.fopen mpackfile $3-
if (!$fread(mpackfile,$file($3-).size,&mpack)) { echo -ca info Error reading $3- . | beep | halt }
if (!$compress(&mpack,bl $+ $2)) { echo -ca info Error compressing $3- . | beep | halt }
.fwrite -n mpack $bvar(&mpack,0) $remove($3-,$mircdir,$shortfn($mircdir))
.fwrite -bn mpack &mpack
.fclose mpackfile
}
else { echo -ca info $3- does not exist. | beep | halt }
}
alias munpack {
var %b = $false , %s = "" , %l = $false , %n = $remove($gettok($longfn($1-),-1,92),.mpk)
if ($1 == -b) { %b = $true | tokenize 32 $2- }
elseif ($1 == -l) { %l = $true | remini $mpacklog %n | tokenize 32 $2- }
elseif ($1 == -lb) || ($1 == -bl) { %b = $true | %l = $true | tokenize 32 $2- }
if ($exists($1-)) {
if ($fopen(mpack)) { .fclose mpack }
.fopen mpack $1-
while (!$feof) {
if (%s) {
if (!$fread(mpack,%m,&mpack)) { echo 04 -a Error reading %f . | .fclose mpack | halt }
if (!$decompress(&mpack,b)) { echo 04 -a Error decompressing %f . | .fclose mpack | halt }
if (!$isdir($deltok(%f,-1,92))) { mkdir $deltok(%f,-1,92) }
if ($isfile(%f)) {
if (%b) { .rename %f %f $+ .bak }
.remove %f
}
if ($bvar(&mpack,0)) {
bwrite %f -1 -1 &mpack
if ($right(%f,4) == mrcl) { .load -rs %f }
if (%l) {
var %x = $calc($ini($mpacklog,%n,0) + 1)
writeini -n $mpacklog %n n $+ %x %f
}
}
%s = ""
}
else {
var %s = $fread(mpack) , %m = $gettok(%s,1,32) , %f = $shortfn($mircdir) $+ $remove($gettok(%s,2-,32),$mircdir,$shortfn($mircdir))
if (%m == <html>) { echo -ca info Error. Not a mpack file. | .fclose mpack | beep | halt }
}
}
.fclose mpack
echo -qcs info $1- mpack file unpacked.
}
else echo -ca info Error. Not such mpack file.
}