From WikiChip
Editing mirc/identifiers/$compress
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
{{mirc title|$compress Identifier}} | {{mirc title|$compress Identifier}} | ||
The '''$compress''' identifier performs compression of a disk file or binary variable. | The '''$compress''' identifier performs compression of a disk file or binary variable. | ||
− | |||
== Synopsis == | == Synopsis == | ||
− | <pre>$compress( <filename | BinaryVariable> ,[b][lN | + | <pre>$compress( <filename | BinaryVariable> ,[b][lN] )</pre> |
== Parameters == | == Parameters == | ||
<span style="display: inline-block; width: 50px;">'''Data'''</span>First parameter can be either a disk file (default) or a Binary Variable<br /> | <span style="display: inline-block; width: 50px;">'''Data'''</span>First parameter can be either a disk file (default) or a Binary Variable<br /> | ||
<span style="display: inline-block; width: 50px;">'''b'''</span>Informs that first parameter should be treated as a Binary Variable instead of filename.<br /> | <span style="display: inline-block; width: 50px;">'''b'''</span>Informs that first parameter should be treated as a Binary Variable instead of filename.<br /> | ||
− | <span style="display: inline-block; width: 50px;">'''lN'''</span>Default compression level is 6 | + | <span style="display: inline-block; width: 50px;">'''lN'''</span>Default compression level is 6 (slower, smallest output). lN overrides to use compression level N, where N is integer 1-6. |
− | |||
== Example == | == Example == | ||
− | There are patterns that often appear near the beginning, but | + | There are patterns that often appear near the beginning, but there's no guaranteed signature to be found at the beginning of a compressed file, except the 1st character is $chr(120) small-x. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | Returns 1 if it compressed the file, or 0 if it did not. It will repeatedly process the same file and return 1, even if the attempt to compress an already compressed file slightly increases the | + | Returns 1 if it compressed the file, or 0 if it did not. It will repeatedly process the same file and return 1, even if the attempt to compress an already compressed file slightly increases the file. 0 can indicate there's no-such-file, the file wasn't already compressed, or a failure to decompress corrupted data. |
<pre> | <pre> | ||
Line 37: | Line 29: | ||
if (!$isfile($2-)) { echo 5 -a filename does not exist: $2- | return } | if (!$isfile($2-)) { echo 5 -a filename does not exist: $2- | return } | ||
bread $qt($2-) 0 1 &snip | bread $qt($2-) 0 1 &snip | ||
− | if ($bvar(&snip,1) != 120) { var %i $compress($2-) | if (%i == 0) echo 5 -a warning failure to | + | if ($bvar(&snip,1) != 120) { var %i $compress($2-) | if (%i == 0) echo 5 -a warning failure to compress $1- } |
dcc send $1 $2- | dcc send $1 $2- | ||
} | } | ||
Line 44: | Line 36: | ||
'''Note:''' Before making a script which automatically compresses all files before sending them and decompressing them when they finish, you should take several issues into account. | '''Note:''' Before making a script which automatically compresses all files before sending them and decompressing them when they finish, you should take several issues into account. | ||
# You shouldn't automatically decompress or compress files without making certain that the same file isn't also being transferred to/from someone else. | # You shouldn't automatically decompress or compress files without making certain that the same file isn't also being transferred to/from someone else. | ||
− | # Besides {{mIRC | + | # Besides {{mIRC|ON FILESENT}}, Transfers can also terminate with {{mIRC|ON SENDFAIL}}, clicking to close the send window, using the /close command with the -s switch, mIRC crashing, etc. |
# To make certain all files get safely decompressed, the script should probably work from a file listing that doesn't remove lines until the file has been determined to be decompressed. | # To make certain all files get safely decompressed, the script should probably work from a file listing that doesn't remove lines until the file has been determined to be decompressed. | ||
− | |||
== Compatibility == | == Compatibility == | ||
{{mIRC compatibility|6.1}} | {{mIRC compatibility|6.1}} | ||
− | |||
== See also == | == See also == | ||
* {{mIRC|$decompress}} | * {{mIRC|$decompress}} | ||
− | [[Category: | + | [[Category:MIRC identifiers]] |