Optimizing FileUtil
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 25 Aug 2012 15:38:01 +0000 (17:38 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sat, 25 Aug 2012 15:38:01 +0000 (17:38 +0200)
wcfsetup/install/files/lib/util/FileUtil.class.php

index c0753930eeb28c14340cd870c8a49597dcd0085a..407938f1356ecd73eb8e80e7e7fc675a0909e99a 100644 (file)
@@ -568,6 +568,9 @@ final class FileUtil {
                        }
                }
                catch (SystemException $e) {
+                       // clean up
+                       if (isset($tmpname) && file_exists($tmpname)) @unlink($tmpname);
+                       
                        throw $e;
                }
        }
@@ -594,7 +597,7 @@ final class FileUtil {
                
                // get bytes
                $block = $file->read($blockSize);
-               return (strlen($block) == 0 || preg_match_all('/\x00/', $block, $match) > 0);
+               return (strlen($block) == 0 || strpos($block, "\0") !== false);
        }
        
        /**