Uncompress swc files (zip-like swf)

@param string $filename
@return boolean|array	false|$width,$height
973771
private function uncompressSwcData($filename) 
	{
	    $size   = 0;
	    $width  = 0;
	    $height = 0;
	
	    $file = @fopen(TL_ROOT . '/' . $filename,"rb");
	    if (!$file) 
	    {
	        return false;
	    }
	    if ("CWS" != fread($file,3)) 
	    {
	        return false;
	    }
	    // Version
	    fread($file,1) ;
	    for ($i=0;$i<4;$i++) 
	    {
	        $t = ord(fread($file,1));
	        $size += ($t<<(8*$i));
	    }
	    $buffer = gzuncompress(gzread($file,$size),$size);
	    $buffer = substr($buffer,0,20); // first 20 Byte enough
	
	    $b = ord(substr($buffer,0,1));
	    $buffer = substr($buffer,1);
	    $cbyte 	= $b;
	    $bits 	= $b>>3;
	
	    $cval 	= "";
	    $cbyte &= 7;
	    $cbyte<<= 5;
	    $cbit 	= 2;
	    // RECT
	    for ($vals=0;$vals<4;$vals++) 
	    {
	        $bitcount = 0;
	        while ($bitcount<$bits) 
	        {
	            if ($cbyte&128) 
	            {
	                $cval .= "1";
	            } 
	            else 
	            {
	                $cval .= "0";
	            }
	            $cbyte<<=1;
	            $cbyte &= 255;
	            $cbit-- ;
	            $bitcount++ ;
	            if ($cbit<0) 
	            {
	                $cbyte	= ord(substr($buffer,0,1));
	                $buffer = substr($buffer,1);
	                $cbit   = 7;
	            }
	        }
	        $c 	    = 1;
	        $val    = 0;
	        $tval   = strrev($cval);
	        $strlen = strlen($tval);
	        for ($n=0; $n<$strlen; $n++) 
	        {
	            $atom = substr($tval,$n,1);
	            if ($atom=="1") $val+=$c;
	            $c*=2;
	        }
	        // TWIPS to PIXELS
	        $val/=20 ;
	        switch ($vals) 
	        {
	            case 0:
	                // tmp value
	                $width = $val;
	                break;
	            case 1:
	                $width = $val - $width;
	                break;
	            case 2:
	                // tmp value
	                $height = $val;
	                break;
	            case 3:
	                $height = $val - $height;
	                break ;
	        }
	        $cval = "";
	    }
	    fclose($file);
	    $buffer ='';
	    return array($width,$height);
	}
847163
private function tryRemoveWithLock(string $fileName): bool
    {
        if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
            // On Windows, unlinking a locked/opened file will not work, so we just attempt the delete straight away.
            // In the worst case, the unlink will just fail due to concurrent access and the caller needs to deal with that.
            return unlink($fileName);
        }
        $file = fopen($fileName, 'rb');
        if ($file === false) {
            return false;
        }

        $result = false;
        if (flock($file, LOCK_EX) !== false) {
            $result = unlink($fileName);
            flock($file, LOCK_UN);
        }
        fclose($file);

        return $result;
    }
1293363
public function delete($filename)
    {
        $this->request->allowMethod(['post', 'delete']);
        $this->BackupManager->delete($this->getFilename($filename));
        $this->Flash->success(I18N_OPERATION_OK);

        return $this->redirect(['action' => 'index']);
    }
88959
public function getFileContent($fileName)
    {
        $Location = array_search($fileName, $this->files, true);
        if (!isset($this->filesData[$fileName])) return false;
        $data = $this->filesData[$fileName];
        $Location_Real = $Location * $this->blockSize;
        if ($this->iso->Seek($Location_Real, SEEK_SET) === false)
            return false;

        return $this->iso->Read($data['size']);
    }
1251092
public function export($filename = null)
	{
		if (!$this->getEnabled()) {
			return false;
		}

		if ($filename === null) {
			$filename = $this->getFilename();
		}

		$path = $this->getPath();

		if (!$this->getBackupFilesystemInstance()->checkPathExists($path)) {
			throw new BackupExportException('Unable to export to path "' . $path . '" as it doesn\'t exist.');
		}

		$filepath = $path . '/' . $filename . '.' . $this->getBackupEngineInstance()->getFileExtension();

        $this->setWorkingFilepath($filepath);
		$result = $this->getBackupEngineInstance()->export($filepath);

		if ($result) {
			if ($this->getCompress()) {
				$filepath = $this->compressFile($filepath);
			}

			$this->setWorkingFilepath($filepath);
		} else {
			$this->removeTemporaryFiles($filepath, true);
			$this->setWorkingFilepath(null);
		}

		return $result;
	}
464367
public static function from($filename)
    {
        $extension = strtok(pathinfo($filename, PATHINFO_EXTENSION), '?');

        return self::getMimeTypeFromExtension($extension);
    }
949945
public function removeWatermark($fileName)
    {
        //check whether files are set or not
        if ($fileName == '')
            throw new Exception('File not specified');

        //build URI to insert watermark image
        $strURI = Product::$baseProductUri . '/words/' . $fileName .
            '/watermark';

        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = Utils::processCommand($signedURI, 'DELETE', '', '');

        $v_output = Utils::validateOutput($responseStream);

        if ($v_output === '') {
            //Save doc on server
            $folder = new Folder();
            $outputStream = $folder->GetFile($fileName);
            $outputPath = AsposeApp::$outPutLocation . $fileName;
            Utils::saveFile($outputStream, $outputPath);
            return $outputPath;
        } else
            return $v_output;
    }
45652
public static function getFileNameWithoutExtension($fileName)
    {
        $matches = [];

        if (is_string($fileName) && (bool)preg_match('|(.+)\.(.+)|', $fileName, $matches)) {
            return $matches[1];
        }

        return '';
    }
1095430
function releaseMutex($filename) {
		$ret = flock($this->fplock[md5($filename)], LOCK_UN);
		fclose($this->fplock[md5($filename)]);
		unset($this->fplock[md5($filename)]);
		if (! $ret) {
			$this->debug("Not able to release lock for $filename");
		}
		return $ret;
	}
540830
public static function split($fileName)
    {
        $ext = pathinfo($fileName);
        return [
            $ext['dirname'],
            $ext['filename'],
            empty($ext['extension']) ? '' : $ext['extension']
        ];
    }
928830
public function pop( $sFileName )
    {
        $sPath = $this->_getCacheFilePath( $sFileName );

        if ( is_null( $sPath ) ) {
            return false;
        }

        if ( $this->_expired( $sPath ) ) {
            @unlink( $sPath );

            return false;
        }

        return unserialize( file_get_contents( $sPath ) );
    }
81928
public static function getSize($filename) {
        if (false === file_exists($filename)) {
            throw new FileNotFoundException($filename);
        }
        clearstatcache();
        return filesize($filename);
    }
802524
public function export_to_file($filename)
    {
        $fh = fopen($filename, 'wb');
        if (!$fh) {
            return false;
        }
        $res = $this->export_to_file_handle($fh);
        fclose($fh);

        return $res;
    }
294576
public static function getFileExtAttr($filename) {
        if (file_exists($filename)) {
            $fp = fileperms($filename) << 16;
            return $fp | (is_dir($filename) ? self::S_DOS_D : self::S_DOS_A);
        }
        return FALSE;
    }
1151541
public function saveBackupTo($filename)
    {
        $result                                   = false;
        $headersBackup                            = $this->defaultHttpHeaders;
        $this->defaultHttpHeaders['Accept']       = '*/*';
        $this->defaultHttpHeaders['Content-Type'] = 'application/x-winstrom-backup';
        $this->performRequest('backup', 'GET');
        $this->defaultHttpHeaders                 = $headersBackup;

        if ($this->lastResponseCode == 200) {
            if (file_put_contents($filename, $this->lastCurlResponse)) {
                $result = true;
            }
        }
        $this->defaultHttpHeaders = $headersBackup;
        return $result;
    }
528311
public static function extractReleaseArchive(string $releaseName): bool
    {
        return Utilities::decompress($releaseName) && Utilities::unpack($releaseName);
    }
53941
public function delete($fileName)
    {
        $path = $this->getPathBase($fileName);

        if (!file_exists($path)) {
            return;
        }

        return unlink($path);
    }