创建空文件

@param string $filename  需要创建的文件

@return mixed
973554
public static function createFile($filename)
    {
        if (is_file($filename)) return false;
        self::createDir(dirname($filename)); //创建目录
        return file_put_contents($filename,'');
    }
111994
protected function getFileName(string $fileName): ?string
    {
        if (!$fileName) {
            return null;
        }

        if (filter_var($fileName, FILTER_VALIDATE_URL)) {

            try {
                $headers = (get_headers($fileName));
            } catch (Throwable $exception) {
                report($exception);
                sleep(1);

                if ($this->headerCallAttempts < 5) {

                    $this->headerCallAttempts++;

                    return $this->getFileName($fileName);
                }

                throw $exception;
            }

            $this->headerCallAttempts = 0;

            foreach ($headers as $header) {
                if (strpos($header, 'filename')) {
                    $name = explode('filename="', $header);
                    $name = rtrim($name[1], '"');

                    $name = explode('.', $name);

                    if (sizeof($name) > 1) {
                        return str_slug(implode('.', $name));
                    }
                }
            }
        }

        $explodeFileURL = explode('/', $fileName);
        $fileName = end($explodeFileURL);

        $explodedByParams = explode('?', $fileName);
        $fileName = head($explodedByParams);

        $string = sanitizeString(pathinfo($fileName, PATHINFO_FILENAME));

        if (strpos($fileName, '.') !== false && substr($fileName, -3) != 'php') {
            return $string . '.' . pathinfo($fileName, PATHINFO_EXTENSION);
        } else {
            return $string;
        }
    }
699929
public function get($filename)
    {
        if (!$stream = $this->readStream($filename)) {
            return false;
        }

        $contents = stream_get_contents($stream);

        fclose($stream);

        return $contents;
    }
767430
protected function checkFileSize($filename) {

        if ( filesize($filename) > $this->config['max_size'] ) {
            $this->errNum = 1;
        }

        //如果是图片还要检查图片的宽度和高度是否超标
        $size = getimagesize($filename);
        if ( $size != false ) {

            $this->fileInfo['is_image'] = 1;
            if ( ($this->config['max_width'] > 0 && $size[0] > $this->config['max_width'])
                || ($this->config['max_height'] > 0 && $size[1] > $this->config['max_height']) )  {
                $this->errNum = 9;
            }
            $this->fileInfo['image_width'] = $size[0];
            $this->fileInfo['image_height'] = $size[1];

        } else {

            $this->fileInfo['is_image'] = 0;

        }

	}
1169420
private function parseFilename($filename) {
    if (defined('DRUPAL_ROOT') && stripos($filename, DRUPAL_ROOT) === 0) {
      return substr($filename, strpos($filename, DRUPAL_ROOT) + strlen(DRUPAL_ROOT) + 1);
    }
    else {
      return $filename;
    }
  }
1345484
public function getFile($filename) {

        $filename = realpath(__DIR__.'/../headers/'.$filename.'.txt');

        if(!file_exists($filename)) throw new \Exception('Filename doesnt exist.');

        return file_get_contents($filename);
    }
393885
public function getContents(string $fileName)
    {
        if (!file_exists($this->__path . $fileName)) {
            return null;
        }
        $r = include $this->__path . $fileName;
        return $r === false ? null : $r;
    }
1012052
protected function extensionOfName($fileName)
    {
        if (mb_strpos($fileName, '.') === false) {
            return mb_strtolower($fileName);
        }

        return mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
    }
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;
    }
572106
public static function check($filename)
    {
        if (!$filename = static::path($filename)) {
            return null;
        }

        if (!file_exists($filename)) {
            return null;
        }

        return filemtime($filename);
    }
506807
public function getPathFromFile($filename)
	{
		$i = strrpos($filename, self::getSlash());

		if ($i!== false)
		{
			return substr($filename, 0, $i);
		}
		else
		{
			return $filename;
		}
	}
1300212
protected function getUniqueFilename($fileName)
    {
        $value = uniqid(md5($fileName));
        $ext = pathinfo($fileName, PATHINFO_EXTENSION);
        if (!empty($ext)){
            $value .= '.' . $ext;
        }
        return static::FILE_DIR . '/' . $value;
    }
1161875
public static function getClassFromFileName($filename)
    {
        $filename = basename($filename);

        $rpos = strrpos($filename, '.');

        if ($rpos != -1) {
            $filename = substr($filename, 0, $rpos);
        }

        return $filename;
    }
342433
protected function getFileName (string $fileName)
    {
        if (!$fileName && filter_var ($fileName, FILTER_VALIDATE_URL) === false) {
            return null;
        }

        $explodeFileURL = explode ('/', $fileName);
        $fileName       = end ($explodeFileURL);

        return sanitizeString (pathinfo ($fileName, PATHINFO_FILENAME)) . '.' . pathinfo ($fileName, PATHINFO_EXTENSION);
    }
768645
protected function cleanupName($filename)
    {
        $filename = str_replace(array('/', '\\', ':', ' '), '_', $filename);
        // Remove dot if it starts with one
        $filename = trim($filename, '.');

        return \MUtil_File::cleanupName($filename);
    }
1171473
public function getFileContent($fileName)
    {
        if (!in_array($fileName, $this->files, true))
            return false;

        return $this->archive->getFileContent($fileName);
    }
506609
public function read($fileName)
    {
        $path = $this->getPathBase($fileName);

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

        $data = file_get_contents($path);
        return $this->data = unserialize($data);
    }