Defines a file.

@param string $key     The key
@param string $content The content
@param int    $mtime   The last modified time (automatically set to now if NULL)
15111
public function setFile($key, $content = null, $mtime = null)
    {
        if (null === $mtime) {
            $mtime = time();
        }

        $this->files[$key] = array(
            'content' => (string) $content,
            'mtime' => (integer) $mtime,
        );
    }
279669
public function set($key, $value, $duration) {
        X::logger()->trace("CCache set $key expire in $duration");
        $file = $this->key2file($key);
        $content = array(
            'key'        => $key,
            'expiration' => $duration > 0 ? time() + $duration : 0,
            'data'       => $value,
        );
        $phpCode = '<?php return ' . Toolkit::compile($content) . ';';
        if (function_exists('opcache_invalidate')) {
            opcache_invalidate($file, true);
        }
        file_put_contents($file, $phpCode, LOCK_EX);
    }
816556
public function writeFile(
        string $content,
        string $filename,
        string $encoding = Encoder::DEFAULT_BYTE_MODE_ECODING,
        ?ErrorCorrectionLevel $ecLevel = null
    ) : void {
        file_put_contents($filename, $this->writeString($content, $encoding, $ecLevel));
    }
658264
function (content) {
      var fileContent = self._readFileSync();

      fileContent.instances = fileContent.instances || {};
      fileContent.instances[this._id] = _.assign(fileContent.instances[this._id] || {}, content);
      self._writeFileSync(fileContent);
    }
1170046
public function store($key, $code, $tag = null, $php = true) {
		$content = "";
		if ($php)
			$content = self::PHP_TAG;
		$content .= $code . "\n";
		$this->storeContent ( $key, $content, $tag );
	}
435852
public function edit($key, Content $content)
    {
        $content->header('Title');
        $content->description('Description');
        $content->body($this->form()->edit($key));
        return $content;
    }
4357
public function setMeta($content)
    {
        $key = '_meta_tags';

        if (!isset($this->data[$key])) {
            $this->data[$key] = array();
        }

        $this->data[$key][] = $content;
    }
839275
public function write($content, array $metadata = null)
    {
        array_walk_recursive($content, function (&$value) {
            if ($value instanceof Closure) {
                $value = new SerializableClosure($value);
            }
        });

        parent::write(serialize($content), $metadata);
    }
910766
public function write ($content)
	{
		$this->createPath($this->path);
		file_put_contents($this->getName(), $content, FILE_APPEND);
	}
765297
private function putContent($file, $content)
    {
        $this->ensureExists(dirname($file));
        touch($file);

        return file_put_contents($file, serialize($content));
    }
307872
public function add(string $content, string $mimeType = null, $encoding = null): void
    {
        $contentPart = $this->make();
        $contentPart->content = $content;
        if ($mimeType !== null) {
            $contentPart->mimeType = $mimeType;
        }
        if ($encoding !== null) {
            $contentPart->encoding = $encoding;
        }
        $this->set($contentPart);
    }
189011
public function setFileRaw( string$key, string$contentType, string$content, string$fileName=null ):self
	{
		$this->files[$key]= [
			'fileName'=> $fileName??md5($content),
			'contentType'=> $contentType,
			'content'=> $content,
		];

		return $this;
	}
357496
public static function add($key, $data, $time = null)
    {
        if (is_callable($data)) {
            $content = $data();
        } else {
            $content = $data;
        }

        $meta['__bow_meta'] = ['expire_at' => $time == null ? '+' : $time];

        $meta['content'] = $content;

        return (bool) file_put_contents(
            static::makeHashFilename($key, true),
            serialize($meta)
        );
    }
725402
public function appendToFile($filename, $content)
    {
        $dir = dirname($filename);

        if (!is_dir($dir)) {
            $this->mkdir($dir);
        }

        if (!is_writable($dir)) {
            throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
        }

        if (false === @file_put_contents($filename, $content, FILE_APPEND)) {
            throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
        }
    }
505293
public static function createFile($file, $content = '')
    {
        $folder = dirname($file);
        if (!is_dir($folder)) {
            self::createFolder($folder);
        }

        file_put_contents($file, $content);
    }
846990
private function createLockFile($content = null)
    {
        if ($this->lockFile) {
            if ($content === null || ! is_string($content)) {
                $content = $this->getId();
            }

            file_put_contents($this->lockFile, $content);
        }
    }
476035
public static function set(string $key, string $value): void
    {
        /* Check if initialized */
        if (!self::$initialized) {
            self::initialize();
        }

        /* Check if key exists */
        if (!self::$configs[$key]) {
            return;
        }

        /* Check if values are the same */
        if (self::$configs[$key] == $value) {
            return;
        }

        /* Write to current array */
        self::$configs[$key] = $value;

        /* Write to file */
        file_put_contents(self::$path, self::convertConfigsToFile());
    }