<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://www.simswiki.info/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://simswiki.info/index.php?action=history&amp;feed=atom&amp;title=Detect_Pets_Body_Shop_bug%2FSource_Code</id>
		<title>Detect Pets Body Shop bug/Source Code - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://simswiki.info/index.php?action=history&amp;feed=atom&amp;title=Detect_Pets_Body_Shop_bug%2FSource_Code"/>
		<link rel="alternate" type="text/html" href="http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;action=history"/>
		<updated>2026-04-14T12:56:20Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.20.2</generator>

	<entry>
		<id>http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;diff=31317&amp;oldid=prev</id>
		<title>Porkypine at 21:37, 6 June 2009</title>
		<link rel="alternate" type="text/html" href="http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;diff=31317&amp;oldid=prev"/>
				<updated>2009-06-06T21:37:09Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 21:37, 6 June 2009&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 485:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 485:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Source Code]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Source Code]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Sims 2]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Porkypine</name></author>	</entry>

	<entry>
		<id>http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;diff=14920&amp;oldid=prev</id>
		<title>Albmont: See also Describe all packages</title>
		<link rel="alternate" type="text/html" href="http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;diff=14920&amp;oldid=prev"/>
				<updated>2007-02-25T17:05:40Z</updated>
		
		<summary type="html">&lt;p&gt;See also Describe all packages&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 17:05, 25 February 2007&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 482:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 482:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* [[CPF/Source Code]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;* [[CPF/Source Code]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;* [[Describe all packages/Source Code]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Source Code]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;[[Category:Source Code]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Albmont</name></author>	</entry>

	<entry>
		<id>http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;diff=14915&amp;oldid=prev</id>
		<title>Albmont: A few minor bug fixes</title>
		<link rel="alternate" type="text/html" href="http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;diff=14915&amp;oldid=prev"/>
				<updated>2007-02-25T16:32:57Z</updated>
		
		<summary type="html">&lt;p&gt;A few minor bug fixes&lt;/p&gt;
&lt;a href=&quot;http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;amp;diff=14915&amp;amp;oldid=13179&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Albmont</name></author>	</entry>

	<entry>
		<id>http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;diff=13179&amp;oldid=prev</id>
		<title>Albmont: /* Source */ Test for NULL in same_index</title>
		<link rel="alternate" type="text/html" href="http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;diff=13179&amp;oldid=prev"/>
				<updated>2007-01-22T12:09:22Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Source: &lt;/span&gt; Test for NULL in same_index&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
			&lt;tr style='vertical-align: top;'&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← Older revision&lt;/td&gt;
			&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Revision as of 12:09, 22 January 2007&lt;/td&gt;
			&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 229:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 229:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;same_index &amp;lt;- function(index, dir)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;same_index &amp;lt;- function(index, dir)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;{&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;{&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; if (is.null(dir))&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160; return(T)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; if (is.null(index$type.id) | is.null(dir$type.id) |&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; is.null(index$group.id)| is.null(dir$group.id) |&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; is.null(index$instance.id) | is.null(dir$instance.id) |&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; is.null(index$location) | is.null(dir$location) |&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160; &amp;#160; is.null(index$size) | is.null(dir$size))&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&amp;#160; &amp;#160; return(T)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; if (index$type.id != dir$type.id)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; if (index$type.id != dir$type.id)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; return(F)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; return(F)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Albmont</name></author>	</entry>

	<entry>
		<id>http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;diff=13124&amp;oldid=prev</id>
		<title>Albmont: Full version</title>
		<link rel="alternate" type="text/html" href="http://simswiki.info/index.php?title=Detect_Pets_Body_Shop_bug/Source_Code&amp;diff=13124&amp;oldid=prev"/>
				<updated>2007-01-21T19:06:29Z</updated>
		
		<summary type="html">&lt;p&gt;Full version&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Overview=&lt;br /&gt;
&lt;br /&gt;
This page contains a code in [http://en.wikipedia.org/wiki/R_(programming_language) R] that finds which clothes were created with the [[Body Shop#The Pets Expansion and Body Shop|Pets EP Bodyshop]] with a bug.&lt;br /&gt;
&lt;br /&gt;
Use at your own risk. Any comments please use the [[Talk:Detect Pets Body Shop bug/Source Code]] page.&lt;br /&gt;
&lt;br /&gt;
=Source=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# read_package: reads a file (passed by filename)&lt;br /&gt;
# and returns a structure&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
library(&amp;quot;bitops&amp;quot;)     # required for bit operations&lt;br /&gt;
library(&amp;quot;survival&amp;quot;)   # required for date/time operations&lt;br /&gt;
&lt;br /&gt;
debug.everything &amp;lt;- F&lt;br /&gt;
&lt;br /&gt;
read_package &amp;lt;- function(filename, get.everything = F)&lt;br /&gt;
{&lt;br /&gt;
  f &amp;lt;- file(filename, open=&amp;quot;rb&amp;quot;)   # open as binary&lt;br /&gt;
  x &amp;lt;- read_package_header(f)      # get the header&lt;br /&gt;
  x$index &amp;lt;- read_package_index_table(f, x)   # get index table&lt;br /&gt;
  x$dir &amp;lt;- read_package_dir(f, x)             # get DIR resource (but won't use it)&lt;br /&gt;
  # set compressed flag whenever index != dir&lt;br /&gt;
  # but won't use this (and this logic is wrong anyway)&lt;br /&gt;
  x$compressed &amp;lt;- NULL&lt;br /&gt;
  for (i in 1:x$n.index)&lt;br /&gt;
    x$compressed[[i]] &amp;lt;- !(same_index(x$index[[i]], x$dir[[i]]))&lt;br /&gt;
  # get the property set&lt;br /&gt;
  x$property.set &amp;lt;- read_package_property_set(f, x)&lt;br /&gt;
  # if this is a CASThumbnails package, do something with it&lt;br /&gt;
  x$thumb1 &amp;lt;- read_package_CASThumbnails(f, x)&lt;br /&gt;
&lt;br /&gt;
  # get all files (not recommended: this is too slow)&lt;br /&gt;
  x$files &amp;lt;- NULL&lt;br /&gt;
  if (get.everything) {&lt;br /&gt;
    x1 &amp;lt;- x&lt;br /&gt;
    for (i in 1:(x$n.index)) {&lt;br /&gt;
      x$files[[i]] &amp;lt;- read_package_file(f, x1, i)&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  # game over&lt;br /&gt;
  close(f)&lt;br /&gt;
  return(x)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
read_package_header &amp;lt;- function(f)&lt;br /&gt;
{&lt;br /&gt;
  x &amp;lt;- NULL    # return value&lt;br /&gt;
  x$dbpf &amp;lt;- readChar(f, 4)  # le char[4]&lt;br /&gt;
  if (x$dbpf != &amp;quot;DBPF&amp;quot;)&lt;br /&gt;
    stop(&amp;quot;Error. Instead of DBPF, I got &amp;quot;, x$dbpf, &amp;quot;\n&amp;quot;)&lt;br /&gt;
  x$major &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)  # major version&lt;br /&gt;
  x$minor &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)  # minor version&lt;br /&gt;
  unused &amp;lt;- readBin(f, &amp;quot;int&amp;quot;, n = 5)  # unused&lt;br /&gt;
  x$index.major &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)  # major version of index; always 7 in TS2&lt;br /&gt;
  x$n.index &amp;lt;- readBin(f, &amp;quot;int&amp;quot;) # number of entries in the index&lt;br /&gt;
  x$first.index &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)  # location of first index entry&lt;br /&gt;
  x$size.index &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)  # size of index&lt;br /&gt;
  x$n.hole &amp;lt;- readBin(f, &amp;quot;int&amp;quot;) # number of hole entries in Hole record&lt;br /&gt;
  x$location.hole &amp;lt;- readBin(f, &amp;quot;int&amp;quot;) # location of Hole record&lt;br /&gt;
  x$size.hole &amp;lt;- readBin(f, &amp;quot;int&amp;quot;) # size of Hole record&lt;br /&gt;
  x$index.minor &amp;lt;- readBin(f, &amp;quot;int&amp;quot;) # Minor Version of index + 1&lt;br /&gt;
  x$index.minor &amp;lt;- x$index.minor - 1&lt;br /&gt;
  reserved &amp;lt;- readBin(f, &amp;quot;int&amp;quot;, n = 8)  # 32 bytes (reserved)&lt;br /&gt;
  return(x)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
read_package_file &amp;lt;- function(f, x1, i.index)&lt;br /&gt;
{&lt;br /&gt;
  file.index &amp;lt;- x1$index[[i.index]]&lt;br /&gt;
  seek(f, file.index$location)&lt;br /&gt;
  f1 &amp;lt;- NULL&lt;br /&gt;
  # compressed files must have a header&lt;br /&gt;
  f1$size &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)   # compressed size of file&lt;br /&gt;
  n &amp;lt;- file.index$size&lt;br /&gt;
  if (n == f1$size) {&lt;br /&gt;
    if (debug.everything) {&lt;br /&gt;
      cat(&amp;quot;file[&amp;quot;, i.index, &amp;quot;] is probably compressed\n&amp;quot;)&lt;br /&gt;
      cat(sprintf(&amp;quot;First 4 bytes at offset %08X = %08X\n&amp;quot;, file.index$location, n))&lt;br /&gt;
    }&lt;br /&gt;
    f1$raw &amp;lt;- read_compressed_file(f, n - 4)&lt;br /&gt;
  }&lt;br /&gt;
  else {&lt;br /&gt;
    seek(f, -4, origin=&amp;quot;current&amp;quot;)&lt;br /&gt;
    f1$raw &amp;lt;- readBin(f, &amp;quot;raw&amp;quot;, n)&lt;br /&gt;
  }&lt;br /&gt;
  f1$human &amp;lt;- convert_raw(f1$raw)  # convert raw to human-readable format&lt;br /&gt;
  return(f1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
read_package_index_table &amp;lt;- function(f, x1)&lt;br /&gt;
{&lt;br /&gt;
  seek(f, where = x1$first.index)&lt;br /&gt;
  t &amp;lt;- NULL&lt;br /&gt;
  for (i in 1:(x1$n.index)) {&lt;br /&gt;
    t[[i]] &amp;lt;- read_package_indexlike_entry(f, x1)&lt;br /&gt;
  }&lt;br /&gt;
  return(t)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
read_package_dir &amp;lt;- function(f, x1)&lt;br /&gt;
{&lt;br /&gt;
  # find if any type.id in index is a DIR&lt;br /&gt;
  i.dir &amp;lt;- 0&lt;br /&gt;
  for (i in 1:(x1$n.index)) {&lt;br /&gt;
    if (x1$index[[i]]$type.id == &amp;quot;E86B1EEF&amp;quot;) {  # DIR&lt;br /&gt;
      i.dir &amp;lt;- i&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  if (i.dir == 0)&lt;br /&gt;
    return(NULL)&lt;br /&gt;
  seek(f, x1$index[[i.dir]]$location)&lt;br /&gt;
  d &amp;lt;- NULL&lt;br /&gt;
  for (i in 1:(x1$n.index)) {&lt;br /&gt;
    d[[i]] &amp;lt;- read_package_indexlike_entry(f, x1, location = x1$index[[i]]$location)&lt;br /&gt;
  }&lt;br /&gt;
  return(d)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# read one block of indexlike entries - used for Index and DIR&lt;br /&gt;
#&lt;br /&gt;
read_package_indexlike_entry &amp;lt;- function(f, x1, location)&lt;br /&gt;
{&lt;br /&gt;
  t1 &amp;lt;- NULL&lt;br /&gt;
  r1 &amp;lt;- readBin(f, &amp;quot;int&amp;quot;, 4, size=1)  # Type ID&lt;br /&gt;
  r1 &amp;lt;- r1 %% 256&lt;br /&gt;
  t1$type.id &amp;lt;- sprintf(&amp;quot;%02X%02X%02X%02X&amp;quot;, r1[4], r1[3], r1[2], r1[1])&lt;br /&gt;
  t1$group.id &amp;lt;- readBin(f, &amp;quot;raw&amp;quot;, 4) # Group ID&lt;br /&gt;
  t1$instance.id &amp;lt;- readBin(f, &amp;quot;raw&amp;quot;, 4) # instance ID&lt;br /&gt;
  if (x1$index.minor == 1)   # version 7.1&lt;br /&gt;
    t1$second.instance.id &amp;lt;- readBin(f, &amp;quot;raw&amp;quot;, 4)  # second instance ID&lt;br /&gt;
  if (missing(location))   # index&lt;br /&gt;
    t1$location &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)  # location of the file&lt;br /&gt;
  else&lt;br /&gt;
    t1$location &amp;lt;- location   # DIR&lt;br /&gt;
  t1$size &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)  # size of the file&lt;br /&gt;
  return(t1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
read_package_property_set &amp;lt;- function(f, x1)&lt;br /&gt;
{&lt;br /&gt;
  # find if any type.id in index is a Property Set&lt;br /&gt;
  i.property.set &amp;lt;- 0&lt;br /&gt;
  for (i in 1:(x1$n.index)) {&lt;br /&gt;
    if (x1$index[[i]]$type.id == &amp;quot;EBCF3E27&amp;quot;) {  # Property Set&lt;br /&gt;
      i.property.set &amp;lt;- i&lt;br /&gt;
      break;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  if (debug.everything)&lt;br /&gt;
    cat(&amp;quot;i.property.set =&amp;quot;, i.property.set, &amp;quot;\n&amp;quot;)&lt;br /&gt;
  if (i.property.set == 0)&lt;br /&gt;
    return(NULL)&lt;br /&gt;
  f1 &amp;lt;- NULL  #&lt;br /&gt;
  if (is.null(f1)) {&lt;br /&gt;
    f1 &amp;lt;- read_package_file(f, x1, i.property.set)&lt;br /&gt;
    return(f1)&lt;br /&gt;
  }&lt;br /&gt;
  # compressed files must have a header&lt;br /&gt;
  f1$size &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)   # compressed size of file&lt;br /&gt;
  f1$qfs &amp;lt;- readBin(f, &amp;quot;raw&amp;quot;, 2)  # 0x10FB&lt;br /&gt;
  f1$uncompressed.size &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)  # 3 bytes or 4 bytes ???&lt;br /&gt;
  r1 &amp;lt;- readBin(f, &amp;quot;int&amp;quot;, 4, size=1)  # Type ID&lt;br /&gt;
  r1 &amp;lt;- r1 %% 256&lt;br /&gt;
  f1$type.id &amp;lt;- sprintf(&amp;quot;%02X%02X%02X%02X&amp;quot;, r1[4], r1[3], r1[2], r1[1])&lt;br /&gt;
  if (f1$type.id != &amp;quot;CBE7505E&amp;quot; &amp;amp;&amp;amp; f1$type.id != &amp;quot;CBE750E0&amp;quot;)&lt;br /&gt;
    return (f1)&lt;br /&gt;
  # CPF&lt;br /&gt;
  f1$version &amp;lt;- readBin(f, &amp;quot;int&amp;quot;, size = 2)&lt;br /&gt;
  f1$n.items &amp;lt;- readBin(f, &amp;quot;int&amp;quot;)&lt;br /&gt;
  f1$items &amp;lt;- NULL&lt;br /&gt;
  for (i in 1:(f1$n.items)) {&lt;br /&gt;
    f2 &amp;lt;- NULL&lt;br /&gt;
    r1 &amp;lt;- readBin(f, &amp;quot;int&amp;quot;, 4, size=1)  # Type ID&lt;br /&gt;
    r1 &amp;lt;- r1 %% 256&lt;br /&gt;
    f2$data.type &amp;lt;- sprintf(&amp;quot;%02X%02X%02X%02X&amp;quot;, r1[4], r1[3], r1[2], r1[1])&lt;br /&gt;
    f2$length &amp;lt;- readBin(f, &amp;quot;int&amp;quot;, size=1)&lt;br /&gt;
    if (debug.everything)&lt;br /&gt;
      cat(&amp;quot;data.type=&amp;quot;, f2$data.type, &amp;quot;length =&amp;quot;, f2$length, &amp;quot;\n&amp;quot;)&lt;br /&gt;
    f2$name &amp;lt;- readBin(f, &amp;quot;character&amp;quot;, f2$length)&lt;br /&gt;
    if (f2$data.type == &amp;quot;EB61E4F7&amp;quot; || f2$data.type == &amp;quot;0C264712&amp;quot;) {   # int&lt;br /&gt;
      f2$data &amp;lt;- readBin(f, &amp;quot;int&amp;quot;, f2$length)&lt;br /&gt;
    }&lt;br /&gt;
    else if (f2$data.type == &amp;quot;0B8BEA18&amp;quot;) {   # string&lt;br /&gt;
      f2$data &amp;lt;- readBin(f, &amp;quot;character&amp;quot;, f2$length)&lt;br /&gt;
    }&lt;br /&gt;
    else if (f2$data.type == &amp;quot;ABC78708&amp;quot;) {   # float (4 bytes)&lt;br /&gt;
      f2$data &amp;lt;- readBin(f, &amp;quot;double&amp;quot;, f2$length, size=4)&lt;br /&gt;
    }&lt;br /&gt;
    else if (f2$data.type == &amp;quot;CBA908E1&amp;quot;) {   # boolean (1 byte)&lt;br /&gt;
      f2$data &amp;lt;- readBin(f, &amp;quot;raw&amp;quot;, f2$length)&lt;br /&gt;
    }&lt;br /&gt;
    f1$items[[i]] &amp;lt;- f2&lt;br /&gt;
  }&lt;br /&gt;
  return(f1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
# depois de pegar o Index tem que pegar o DIR resource&lt;br /&gt;
# que comeca com ef 1e 6b e8&lt;br /&gt;
# CTSS = 53 53 54 43&lt;br /&gt;
# XML = 25 e9 a8 cc&lt;br /&gt;
# STR# = 23 52 54 53&lt;br /&gt;
# Property Set = EBCF3E27&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
read_package_CASThumbnails &amp;lt;- function(f, x1)&lt;br /&gt;
{&lt;br /&gt;
  if (x1$n.index &amp;lt;= 0)&lt;br /&gt;
    return(NULL)&lt;br /&gt;
  if (x1$index[[1]]$type.id != &amp;quot;0C7E9A76&amp;quot;)&lt;br /&gt;
    return(NULL)&lt;br /&gt;
  f1 &amp;lt;- NULL  #&lt;br /&gt;
  if (is.null(f1)) {&lt;br /&gt;
    f1 &amp;lt;- read_package_file(f, x1, 1)&lt;br /&gt;
  }&lt;br /&gt;
  return(f1)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# Check if the entry from &amp;quot;index&amp;quot; is the same as from &amp;quot;dir&amp;quot;&lt;br /&gt;
#&lt;br /&gt;
same_index &amp;lt;- function(index, dir)&lt;br /&gt;
{&lt;br /&gt;
  if (index$type.id != dir$type.id)&lt;br /&gt;
    return(F)&lt;br /&gt;
  if (any(index$group.id != dir$group.id))&lt;br /&gt;
    return(F)&lt;br /&gt;
  if (any(index$instance.id != dir$instance.id))&lt;br /&gt;
    return(F)&lt;br /&gt;
  if (index$location != dir$location)&lt;br /&gt;
    return(F)&lt;br /&gt;
  if (index$size != dir$size)&lt;br /&gt;
    return(F)&lt;br /&gt;
  return(T)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# read_compressed_file is dmchess's try_decompress&lt;br /&gt;
#&lt;br /&gt;
read_compressed_file &amp;lt;- function(FH, len, try_decompress = T)&lt;br /&gt;
{&lt;br /&gt;
  if (!try_decompress) {&lt;br /&gt;
    if (debug.everything)&lt;br /&gt;
      cat(&amp;quot;Reading&amp;quot;, len, &amp;quot;bytes as raw\n&amp;quot;)&lt;br /&gt;
    answer &amp;lt;- readBin(FH, &amp;quot;raw&amp;quot;, len - 4)&lt;br /&gt;
    return(answer)&lt;br /&gt;
  }&lt;br /&gt;
  header &amp;lt;- readBin(FH, &amp;quot;int&amp;quot;, 5, size=1) %% 256 # first five bytes&lt;br /&gt;
  if (debug.everything)&lt;br /&gt;
    cat(sprintf(&amp;quot;header = %02X %02X %02X %02X %02X\n&amp;quot;, &lt;br /&gt;
      header[1], header[2], header[3], header[4], header[5]));&lt;br /&gt;
  len &amp;lt;- len - 5&lt;br /&gt;
  answer &amp;lt;- NULL&lt;br /&gt;
  answerlen &amp;lt;- 0&lt;br /&gt;
  byte1 &amp;lt;- byte2 &amp;lt;- byte3 &amp;lt;- 0&lt;br /&gt;
  # begin of dmchess's try_decompress perl code converted to R&lt;br /&gt;
  sp &amp;lt;- seek(FH, where=NA) # my $sp = tell FH&lt;br /&gt;
  while (len &amp;gt; 0) {&lt;br /&gt;
    cc &amp;lt;- readBin(FH, &amp;quot;int&amp;quot;, 1, size=1) %% 256 # read FH,$buf,1; my $cc = unpack &amp;quot;C&amp;quot;, $buf;&lt;br /&gt;
    len &amp;lt;- len - 1 # $len -= 1;&lt;br /&gt;
#    printf &amp;quot;      Control char is %02x, len remaining is %08x. \n&amp;quot;,$cc,$len;&lt;br /&gt;
    if (cc &amp;gt;= 0xfc) {&lt;br /&gt;
      numplain &amp;lt;- bitAnd(cc, 0x03) # $numplain = $cc &amp;amp; 0x03;&lt;br /&gt;
      if (numplain &amp;gt; len) numplain &amp;lt;- len # $numplain = $len if ($numplain &amp;gt; $len);&lt;br /&gt;
      numcopy &amp;lt;- 0&lt;br /&gt;
      offset &amp;lt;- 0&lt;br /&gt;
    } &lt;br /&gt;
    else if (cc &amp;gt;= 0xe0)  {&lt;br /&gt;
      numplain &amp;lt;- bitShiftL(cc - 0xdf, 2) # $numplain = ($cc - 0xdf) &amp;lt;&amp;lt; 2; &lt;br /&gt;
      numcopy &amp;lt;- 0&lt;br /&gt;
      offset &amp;lt;- 0&lt;br /&gt;
    } &lt;br /&gt;
    else if (cc &amp;gt;= 0xc0) {&lt;br /&gt;
      len &amp;lt;- len - 3 # $len -= 3;&lt;br /&gt;
      byte1 &amp;lt;- readBin(FH, &amp;quot;int&amp;quot;, 1, size=1) %% 256 # read FH,$buf,1; my $byte1 = unpack &amp;quot;C&amp;quot;, $buf;&lt;br /&gt;
      byte2 &amp;lt;- readBin(FH, &amp;quot;int&amp;quot;, 1, size=1) %% 256 # read FH,$buf,1; my $byte2 = unpack &amp;quot;C&amp;quot;, $buf;&lt;br /&gt;
      byte3 &amp;lt;- readBin(FH, &amp;quot;int&amp;quot;, 1, size=1) %% 256 # read FH,$buf,1; my $byte3 = unpack &amp;quot;C&amp;quot;, $buf;&lt;br /&gt;
      numplain &amp;lt;- bitAnd(cc, 0x03) # $numplain = $cc &amp;amp; 0x03;&lt;br /&gt;
      numcopy &amp;lt;- bitShiftL(bitAnd(cc, 0x0c), 6) + 5 + byte3 # $numcopy = (($cc &amp;amp; 0x0c) &amp;lt;&amp;lt;6) + 5 + $byte3;&lt;br /&gt;
      offset &amp;lt;- bitShiftL(bitAnd(cc, 0x10), 12) + bitShiftL(byte1, 8) + byte2 # ...&lt;br /&gt;
      # $offset = (($cc &amp;amp; 0x10) &amp;lt;&amp;lt; 12 ) + ($byte1 &amp;lt;&amp;lt; 8) + $byte2;&lt;br /&gt;
    } &lt;br /&gt;
    else if (cc &amp;gt;= 0x80) {&lt;br /&gt;
      len &amp;lt;- len - 2 # $len -= 2;&lt;br /&gt;
      byte1 &amp;lt;- readBin(FH, &amp;quot;int&amp;quot;, 1, size=1) %% 256 # read FH,$buf,1; my $byte1 = unpack &amp;quot;C&amp;quot;, $buf;&lt;br /&gt;
      byte2 &amp;lt;- readBin(FH, &amp;quot;int&amp;quot;, 1, size=1) %% 256 # read FH,$buf,1; my $byte2 = unpack &amp;quot;C&amp;quot;, $buf;&lt;br /&gt;
      numplain &amp;lt;- bitShiftR(bitAnd(byte1, 0xc0), 6) # $numplain = ($byte1 &amp;amp; 0xc0) &amp;gt;&amp;gt; 6;&lt;br /&gt;
      numcopy &amp;lt;- bitAnd(cc, 0x3f) + 4 # $numcopy = ($cc &amp;amp; 0x3f) + 4;&lt;br /&gt;
      offset &amp;lt;- bitShiftL(bitAnd(byte1, 0x3f), 8) + byte2 # $offset = (($byte1 &amp;amp; 0x3f) &amp;lt;&amp;lt; 8) + $byte2;&lt;br /&gt;
    } &lt;br /&gt;
    else {&lt;br /&gt;
      byte1 &amp;lt;- readBin(FH, &amp;quot;int&amp;quot;, 1, size=1) %% 256 # read FH,$buf,1; my $byte1 = unpack &amp;quot;C&amp;quot;, $buf;&lt;br /&gt;
#      cat(&amp;quot;byte1 = &amp;quot;, byte1, &amp;quot;\n&amp;quot;)&lt;br /&gt;
      len &amp;lt;- len - 1 # $len -= 1;&lt;br /&gt;
      numplain &amp;lt;- bitAnd(cc, 0x03) # $numplain = ($cc &amp;amp; 0x03);&lt;br /&gt;
      numcopy &amp;lt;- bitShiftR(bitAnd(cc, 0x1c), 2) + 3 # $numcopy = (($cc &amp;amp; 0x1c) &amp;gt;&amp;gt; 2) + 3;&lt;br /&gt;
      offset &amp;lt;- bitShiftL(bitAnd(cc, 0x60), 3) + byte1 # $offset = (($cc &amp;amp; 0x60) &amp;lt;&amp;lt; 3) + $byte1;&lt;br /&gt;
    }&lt;br /&gt;
#    printf &amp;quot;      plain, copy, offset: $numplain, $numcopy, $offset \n&amp;quot;;&lt;br /&gt;
    len &amp;lt;- len - numplain # $len -= $numplain;&lt;br /&gt;
    if (numplain &amp;gt; 0) {   # perl didn't check this&lt;br /&gt;
      buf &amp;lt;- readBin(FH, &amp;quot;raw&amp;quot;, numplain) # read FH,$buf,$numplain;&lt;br /&gt;
      answer &amp;lt;- c(answer, buf) # $answer = $answer.$buf;&lt;br /&gt;
    }&lt;br /&gt;
    fromoffset &amp;lt;- length(answer) - (offset + 1) # my $fromoffset = length($answer) - ($offset + 1);  # 0 == last char&lt;br /&gt;
&lt;br /&gt;
    if (numcopy &amp;gt; 0)&lt;br /&gt;
      answer &amp;lt;- c(answer, answer[(fromoffset+1):(fromoffset+numcopy)])&lt;br /&gt;
#&lt;br /&gt;
#    for ($i=0;$i&amp;lt;$numcopy;$i++) {&lt;br /&gt;
#      $answer = $answer.substr($answer,$fromoffset+$i,1);&lt;br /&gt;
#    }&lt;br /&gt;
    answerlen &amp;lt;- answerlen + numplain # $answerlen += $numplain;&lt;br /&gt;
    answerlen &amp;lt;- answerlen + numcopy  # $answerlen += $numcopy;&lt;br /&gt;
    if (debug.everything) {&lt;br /&gt;
      cat(&amp;quot;     cc=&amp;quot;, sprintf(&amp;quot;%x&amp;quot;, cc), &amp;quot;\n&amp;quot;)&lt;br /&gt;
      cat(&amp;quot;     byte1 =&amp;quot;, byte1, &amp;quot;byte2 =&amp;quot;, byte2, &amp;quot;\n&amp;quot;)&lt;br /&gt;
      cat(&amp;quot;     numplain =&amp;quot;, numplain, &amp;quot;numcopy =&amp;quot;, numcopy, &lt;br /&gt;
        &amp;quot;offset =&amp;quot; , offset, &amp;quot;fromoffset =&amp;quot;, fromoffset, &amp;quot;\n&amp;quot;) &lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    if (len &amp;lt; 0)&lt;br /&gt;
      cat(&amp;quot;     UNDERFLOW\n&amp;quot;) # if ($len&amp;lt;0) { printf &amp;quot;      UNDERFLOW \n&amp;quot;; }&lt;br /&gt;
&lt;br /&gt;
  }&lt;br /&gt;
  # printf(   &amp;quot;      Answer length is %08x (%08x). \n&amp;quot;, answerlen, length(answer)) # ...&lt;br /&gt;
  # printf &amp;quot;      Answer length is %08x (%08x). \n&amp;quot;,$answerlen,length($answer);&lt;br /&gt;
&lt;br /&gt;
  seek(FH, sp) # seek FH,$sp,0;&lt;br /&gt;
  return(answer) # return $answer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
convert_raw &amp;lt;- function(raw)&lt;br /&gt;
{&lt;br /&gt;
  if (any(as.integer(raw[1:4]) == c(0xe0, 0x50, 0xe7, 0xcb)))&lt;br /&gt;
    return(convert_cpf(raw[-(1:4)]))&lt;br /&gt;
  return(NULL)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
convert_cpf &amp;lt;- function(raw)&lt;br /&gt;
{&lt;br /&gt;
  cpf &amp;lt;- NULL&lt;br /&gt;
  cpf$id &amp;lt;- &amp;quot;CPF&amp;quot;&lt;br /&gt;
  cpf$version &amp;lt;- get_little_endian(raw, 2)&lt;br /&gt;
  n &amp;lt;- get_little_endian(raw[3:6], 4)&lt;br /&gt;
  cpf$data &amp;lt;- NULL&lt;br /&gt;
  pos &amp;lt;- 7&lt;br /&gt;
  for (i in 1:n) {&lt;br /&gt;
    xtype &amp;lt;- get_little_endian(raw[pos:(pos+3)], 4)&lt;br /&gt;
    pos &amp;lt;- pos + 4&lt;br /&gt;
    nlen &amp;lt;- get_little_endian(raw[pos:(pos+3)], 4)  # len of field name&lt;br /&gt;
    pos &amp;lt;- pos + 4&lt;br /&gt;
    # the code below is very stupid, but I don't know how to do it in an intelligent way&lt;br /&gt;
    name &amp;lt;- rawToChar(raw[pos:(pos+nlen-1)])&lt;br /&gt;
    pos &amp;lt;- pos + nlen&lt;br /&gt;
    if (xtype == 0xEB61E4F7 || xtype == 0x0C264712 || xtype == 0xABC78708) {  # integer or float&lt;br /&gt;
      data &amp;lt;- get_little_endian(raw[pos:(pos+3)], 4)&lt;br /&gt;
      pos &amp;lt;- pos + 4&lt;br /&gt;
      cpf[[name]] &amp;lt;- data&lt;br /&gt;
    }&lt;br /&gt;
    else if (xtype == 0x0B8BEA18) { # string&lt;br /&gt;
      slen &amp;lt;- get_little_endian(raw[pos:(pos+3)], 4)&lt;br /&gt;
      pos &amp;lt;- pos + 4&lt;br /&gt;
      str &amp;lt;- rawToChar(raw[pos:(pos+slen-1)])&lt;br /&gt;
      pos &amp;lt;- pos + slen&lt;br /&gt;
      cpf[[name]] &amp;lt;- str&lt;br /&gt;
    }&lt;br /&gt;
    else if (xtype == 0xCBA908E1) { # boolean&lt;br /&gt;
      cpf[[name]] &amp;lt;- raw[pos]&lt;br /&gt;
      pos &amp;lt;- pos + 1&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  return(cpf)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_little_endian &amp;lt;- function(bytes, n)&lt;br /&gt;
{&lt;br /&gt;
# I bet there's a more elegant way to do this&lt;br /&gt;
  return(sum(256^(0:(n-1)) * as.integer(bytes[1:n])))&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# The next routine opens _all_ package files since&lt;br /&gt;
# some date and tests if it was infected by the bug&lt;br /&gt;
# in the Pets EP Bodyshop. start_date must be passed&lt;br /&gt;
# as an ISO-8601 string.&lt;br /&gt;
#&lt;br /&gt;
find_pets_ep_bug &amp;lt;- function(start_date = as.POSIXlt(&amp;quot;2006-10-01&amp;quot;, &amp;quot;GMT&amp;quot;))&lt;br /&gt;
{&lt;br /&gt;
  # create vector with all filenames that end in .package&lt;br /&gt;
  fnlist &amp;lt;- list.files(pattern = &amp;quot;.package$&amp;quot;) &lt;br /&gt;
  for (i in 1:length(fnlist)) {&lt;br /&gt;
    filename &amp;lt;- fnlist[i]&lt;br /&gt;
    # get modification time of package&lt;br /&gt;
    m_date  &amp;lt;- as.POSIXlt(file.info(filename)$mtime, &amp;quot;GMT&amp;quot;)&lt;br /&gt;
    # skip if package is older than start date&lt;br /&gt;
    if (m_date &amp;lt; start_date)&lt;br /&gt;
      next  # in C or similar languages, this would be a continue&lt;br /&gt;
    # now let's do the hard work&lt;br /&gt;
    x &amp;lt;- read_package(filename, get.everything = F)&lt;br /&gt;
    # there should be some sanity checks here!&lt;br /&gt;
    if (is.null(x$property.set)) next&lt;br /&gt;
    if (is.null(x$property.set$human)) next&lt;br /&gt;
    if (is.null(x$property.set$human$type)) next&lt;br /&gt;
    if (is.null(x$property.set$human$type != &amp;quot;skin&amp;quot;)) next&lt;br /&gt;
    # everything suggests that this is a recolor / outfit / clothing&lt;br /&gt;
    if (is.null(x$property.set$human$outfit)) &lt;br /&gt;
      cat(filename, &amp;quot;seems to include the Pets EP Bodyshop bug\n&amp;quot;)&lt;br /&gt;
  }&lt;br /&gt;
  # done&lt;br /&gt;
  cat(&amp;quot;Total of&amp;quot;, length(fnlist), &amp;quot;files processed\n&amp;quot;)&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=See Also=&lt;br /&gt;
&lt;br /&gt;
* [[CPF/Source Code]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Source Code]]&lt;/div&gt;</summary>
		<author><name>Albmont</name></author>	</entry>

	</feed>