I came across a few bugs compiling PhysFS with msvc9 - I&#39;ve created a patch which seems to fix them:<br>SzFileReadImp / SzFileSeekImp:<br>Problem: Can&#39;t preform arithmatic on &#39;void *&#39;<br>Fix: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Cast &#39;object&#39; to unsigned long<br>
<br>LZMA_enumerateFiles:<br>Problem: There is no error handling if the directory &#39;dname&#39; doesn&#39;t exist<br>Fix:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Check the return value of &#39;lzma_find_file()&#39; before using it<br><br>LZMA_isDirectory:<br>
Problem: return (file-&gt;item-&gt;IsDirectory) is illegal if &#39;file&#39; doesn&#39;t exist<br>Fix:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Make sure &#39;file&#39; isn&#39;t null before returning<br><br>---------------<br>The patch:<br><br>Index: lzma.c<br>
===================================================================<br>--- lzma.c&nbsp;&nbsp;&nbsp; (revision 927)<br>+++ lzma.c&nbsp;&nbsp;&nbsp; (working copy)<br>@@ -130,7 +130,7 @@<br>&nbsp;SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size_t *processedSize)<br>&nbsp;{<br>-&nbsp;&nbsp;&nbsp; FileInputStream *s = (FileInputStream *)(object - offsetof(FileInputStream, inStream)); // HACK!<br>+&nbsp;&nbsp;&nbsp; FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); // HACK!<br>
&nbsp;&nbsp;&nbsp;&nbsp; size_t processedSizeLoc = __PHYSFS_platformRead(s-&gt;file, buffer, 1, size);<br>&nbsp;&nbsp;&nbsp;&nbsp; if (processedSize != 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *processedSize = processedSizeLoc;<br>@@ -145,7 +145,7 @@<br>&nbsp; */<br>&nbsp;SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)<br>
&nbsp;{<br>-&nbsp;&nbsp;&nbsp; FileInputStream *s = (FileInputStream *)(object - offsetof(FileInputStream, inStream)); // HACK!<br>+&nbsp;&nbsp;&nbsp; FileInputStream *s = (FileInputStream *)((unsigned long)object - offsetof(FileInputStream, inStream)); // HACK!<br>
&nbsp;&nbsp;&nbsp;&nbsp; if (__PHYSFS_platformSeek(s-&gt;file, (PHYSFS_uint64) pos))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return SZ_OK;<br>&nbsp;&nbsp;&nbsp;&nbsp; return SZE_FAIL;<br>@@ -563,8 +563,18 @@<br>&nbsp;&nbsp;&nbsp;&nbsp; size_t dlen = strlen(dname),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dlen_inc = dlen + ((dlen &gt; 0) ? 1 : 0);<br>
&nbsp;&nbsp;&nbsp;&nbsp; LZMAarchive *archive = (LZMAarchive *) opaque;<br>-&nbsp;&nbsp;&nbsp; LZMAfile *file = (dlen ? lzma_find_file(archive, dname) + 1 : archive-&gt;files),<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *lastFile = &amp;archive-&gt;files[archive-&gt;db.Database.NumFiles];<br>
+&nbsp;&nbsp;&nbsp; LZMAfile *file = NULL,<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *lastFile = &amp;archive-&gt;files[archive-&gt;db.Database.NumFiles];<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (dlen)<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; file = lzma_find_file(archive, dname);<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (file != NULL) // if &#39;file&#39; is NULL it should stay so, otherwise errors will not be handled<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; file += 1;<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; file = archive-&gt;files;<br>+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; BAIL_IF_MACRO(file == NULL, ERR_NO_SUCH_FILE, );<br>&nbsp;<br>@@ -620,7 +630,7 @@<br>
&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp; *fileExists = (file != NULL);<br>&nbsp;<br>-&nbsp;&nbsp;&nbsp; return(file-&gt;item-&gt;IsDirectory);<br>+&nbsp;&nbsp;&nbsp; return(file == NULL ? 0 : file-&gt;item-&gt;IsDirectory);<br>&nbsp;} /* LZMA_isDirectory */<br>&nbsp;<br>&nbsp;<br>--end of patch-----------------------------------------------------------<br>
<br>-- <br><a href="http://steelfusion.sourceforge.net">http://steelfusion.sourceforge.net</a>