exifRotation - return the exif rotation
@param  String $FileName
@return Int false|angle
174571
private function exifRotation($file)
    {
        if (!function_exists('exif_read_data')) {
            return false;
        }

        $exif = @exif_read_data($file);

        if (!$exif) {
            return false;
        }

        $ort = @$exif['IFD0']['Orientation'];

        if (!$ort) {
            $ort = @$exif['Orientation'];
        }

        switch ($ort) {
            case 3: // image upside down
                return '180';
                break;
            case 6: // 90 rotate right
                return '-90';
                break;
            case 8: // 90 rotate left
                return '90';
                break;
            default:
                return false;
        }
    }
484962
function size($filename)
    {
        if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
            return false;
        }

        $result = $this->stat($filename);
        if ($result === false) {
            return false;
        }
        return isset($result['size']) ? $result['size'] : -1;
    }
297207
public function imageInfo($fileName)
    {
        if ($fileName instanceof ImageInterface) {
            return $fileName;
        }

        $image = $this->filesystem->getFile('files://' . $fileName, new NullableImage());

        return $image;
    }
1332608
public static function getExifRotation($source)
    {
        if (!Kwf_Registry::get('config')->image->autoExifRotate) {
            return 0;
        }

        $handle = fopen($source, 'rb'); // b for windows compatibility
        // Check if image is jpg file
        if (fread($handle, 2) != chr(0xFF).chr(0xD8)) {
            fclose($handle);
            return 0;
        }

        $fileSize = filesize($source);
        $count = 0;
        $rotation = 0;
        while ($count < 3) { // Run through marker
            $count++;
            $marker = fread($handle, 2);
            // Marks start of stream (SOS)
            if ($marker == chr(0xFF).chr(0xDA)) break;

            $size = self::_generateIntValue(fread($handle, 1), fread($handle, 1), false);
            if ($marker == chr(0xFF).chr(0xE1)) { // Start of exif-data-block
                if (fread($handle, 6) != 'Exif'.chr(0).chr(0)) break;

                $tiffHeaderBytes = fread($handle, 4); // should be 0x49492A00 or 0x4D4D002A
                if ($tiffHeaderBytes == 'II'.chr(0x2A).chr(0x00)) { // Motorola
                    $reversed = true;
                } else if ($tiffHeaderBytes == 'MM'.chr(0x00).chr(0x2A)) { // Intel
                    $reversed = false;
                } else { // this case should not exist
                    break;
                }

                $count = 0;
                while ($count < 5) {
                    $count++;
                    // IFD = Image File Directory => Image properties
                    // check offset from tiffHeader-Start to IFD's, if 0 end of all IFD-Blocks
                    if (fread($handle, 4) == chr(0x00).chr(0x00).chr(0x00).chr(0x00)) break 2;

                    $ifdCount = self::_generateIntValue(fread($handle, 1), fread($handle, 1), $reversed);
                    if ($fileSize < ftell($handle) + $ifdCount * 12 + 6) break 2; // check to handle eof
                    if ($ifdCount > 100) break 2; // check if ifdCount is a possible value
                    for ($i = 0; $i < $ifdCount; $i++) {
                        $ifdBytes = fread($handle, 12);
                        $tag = self::_generateIntValue($ifdBytes[0], $ifdBytes[1], $reversed);
                        if ($tag == 0x0112) {
                            // reversed saved in this form: 00 06 | 00 00 should be 00 00 | 00 06
                            // normally saved in this form: 06 00 | 00 00
                            $highBytes = self::_generateIntValue($ifdBytes[10], $ifdBytes[11], $reversed);
                            $lowBytes = self::_generateIntValue($ifdBytes[8], $ifdBytes[9], $reversed);
                            $exifOrientation = $highBytes * pow(16, 4) + $lowBytes;
                            switch ($exifOrientation) {
                                case 1:
                                    $rotation = 0;
                                    break;
                                case 8: //Left_Bottom
                                    $rotation = -90;
                                    break;
                                case 3:
                                    $rotation = 180;
                                    break;
                                case 6: //Right_Top
                                    $rotation = 90;
                                    break;
                            }
                            break 3;
                        }
                    }
                }

            } else { // Any other marker (e.g. JFIF-0xFFE0, Photoshop-Stuff), not supported. Set file-pointer to end of marker-data
                fseek($handle, $size -2, SEEK_CUR);
            }
        }
        fclose($handle);
        return $rotation;
    }
316283
function obtainMutex($filename, $mode)
    {
        if (isset($this->fplock[md5($filename)])) {
            $this->debug("Lock for $filename already exists");

            return FALSE;
        }
        $this->fplock[md5($filename)] = fopen($filename . ".lock", "w");
        if ($mode == "r") {
            return flock($this->fplock[md5($filename)], LOCK_SH);
        } else {
            return flock($this->fplock[md5($filename)], LOCK_EX);
        }
    }
1045674
static function rotateLog( $fileName )
    {
        $maxLogrotateFiles = eZDebug::maxLogrotateFiles();
        if ( $maxLogrotateFiles == 0 )
        {
            return;
        }
        for ( $i = $maxLogrotateFiles; $i > 0; --$i )
        {
            $logRotateName = $fileName . '.' . $i;
            if ( file_exists( $logRotateName ) )
            {
                if ( $i == $maxLogrotateFiles )
                {
                    @unlink( $logRotateName );
                }
                else
                {
                    $newLogRotateName = $fileName . '.' . ($i + 1);
                    eZFile::rename( $logRotateName, $newLogRotateName );
                }
            }
        }
        if ( file_exists( $fileName ) )
        {
            $newLogRotateName = $fileName . '.' . 1;
            eZFile::rename( $fileName, $newLogRotateName );
            return true;
        }
        return false;
    }
1240715
public function parseFile($filename)
    {
        $data = @parse_ini_file($filename, true);
        return $this->parse($data, $filename);
    }
1305014
public function getFilePath($filename)
    {
        if (modules()) {
            $filePaths = modules()->getDirs('Views');
        } else {
            $filePaths = array_reverse($this->filePaths);
        }

        foreach ($filePaths as $filePath) {
            if (is_file($filePath . $filename . '.phtml')) {
                return $filePath . $filename . '.phtml';
                break;
            } elseif (is_file($filePath . 'errors' . DIRECTORY_SEPARATOR . $filename . '.phtml')) {
                return $filePath . 'errors' . DIRECTORY_SEPARATOR . $filename . '.phtml';
                break;
            }
        }
    }
978425
public function rotate( File $file, $rotation ) {
		$params = [
			'rotation' => $rotation,
			'token' => $this->api->getToken(),
		];

		if ( !is_null( $file->getPageIdentifier()->getTitle() ) ) {
			$params['titles'] = $file->getPageIdentifier()->getTitle()->getText();
		} else {
			$params['pageids'] = $file->getPageIdentifier()->getId();
		}

		$result = $this->api->postRequest( new SimpleRequest( 'imagerotate', $params ) );

		// This module sometimes gives odd errors so deal with them..
		if ( array_key_exists( 'imagerotate', $result ) ) {
			$imageRotate = array_pop( $result['imagerotate'] );
			if ( array_key_exists( 'result', $imageRotate ) &&
				$imageRotate['result'] == 'Failure'
			) {
				throw new UsageException(
					'imagerotate-Failure',
					$imageRotate['errormessage'],
					$result
				);
			}
		}

		return true;
	}
318495
public function rotate($force = false)
    {
        $rotator = $this->options['backup_time'];

        if (true===$force || $this->mustRotate()) {
            $dir = dirname($this->file_path);
            $old_file = $this->getFilename(basename($this->file_path), $rotator);
            if (file_exists($dir . '/' . $old_file)) {
                @unlink($dir . '/' . $old_file);
            }
            if (false!==strpos($this->flag, $this->options['filename_iterator_tag'])) {
                while ($rotator-- > 0) {
                    $original_file = $this->getFilename(basename($this->file_path), $rotator);
                    if (file_exists($dir . '/' . $original_file)) {
                        $target_file = $this->getFilename(basename($this->file_path), ($rotator + 1));
                        $ok = @rename($dir . '/' . $original_file, $dir . '/' . $target_file);
                    }
                }
            } else {
                $target_file = $this->getFilename(basename($this->file_path), 1);
                $ok = @rename($this->file_path, $dir . '/' . $target_file);
            }
            return $ok;
        }
        return true;
    }
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;
    }
697162
public function setFileName($filename)
  {
    if ($this->isLocked()) {
      return $this->getObj()->setFileName($filename)->setLocked();
    } else {
      return parent::setFileName($filename);
    }
  }
213190
static public function touch($filename)
	{
	    $ret = true;
	    if ($filename && !file_exists($filename)) {
	        $ret = static::write($filename, '');
	    }
	    return $ret;
	}
1064409
public function getImageByName($filename)
    {
        $images = $this->getImages();
        foreach ($images as $image) {
            if ($image->file == $filename) {
                return $image;
            }
        }

        return null;
    }
542269
function size($filename)
    {
        if (!($this->bitmap & SSH2::MASK_LOGIN)) {
            return false;
        }

        $result = $this->stat($filename);
        if ($result === false) {
            return false;
        }
        return isset($result['size']) ? $result['size'] : -1;
    }
506132
private function getAliasedUri($fileName, $alias)
    {
        if ($fileName === null) {
            return false;
        }

        if (!$this->isAlias($alias)) {
            return false;
        }

        // If we're passing in an image as array, instead of a single filename.
        $fileName = $this->normalizeFileName($fileName);

        return $this->urlGenerator->generate(
            'thumb_alias',
            [
                'alias'  => $alias,
                'file'   => $fileName,
            ]
        );
    }
636608
private function rotateLogFile($filename)
    {
        if (!file_exists($filename) && !touch($filename)) {
            throw new ExtensionException(
                sprintf('Handler (%s) accept only stringable filename. Resource will converter automatically', static::class));
        }
        
        $file = new \SplFileObject($filename);
        
        if ($file->getSize() > static::MAX_LOG_SIZE) {
            
            $iterator = new \GlobIterator(sprintf('%s/%s.*.gz',
                $file->getPath(), $file->getBasename()), \FilesystemIterator::SKIP_DOTS);
            
            $gzFilepath = sprintf('%s/%s.%d.gz',
                $file->getPath(), $file->getBasename(), $iterator->count());
            
            $gzip = gzopen($gzFilepath, 'w9');
            gzwrite($gzip, $file->fread($file->getSize()));
            gzclose($gzip);
            
            unlink($file->getPathname());
            touch($file->getPathname());
        }
        
        return $filename;
    }