Serializes and saves $data in the file $path and sets the last modified time to $mtime

@param string $path  filename to save data in
@param mixed  $data  data to be serialized and saved
@param int    $mtime Last modified date in epoch time
773903
public static function write($path, $data, $mtime = 0)
    {
        if (!file_exists(dirname($path))) {
            self::mkdir(dirname($path), 0755, true);
        }
        if (file_put_contents($path, serialize($data), LOCK_EX)) {
            $mtime = ($mtime > 0) ? $mtime : time();
            @chmod($path, 0777);
            @touch($path, $mtime);
        }
    }
628393
private function SaveToPHP($path)
    {
        $this->definitions_path = rtrim($path, "/\\") . "/";
        $this->export_type = Type::PHP;
        
        $this->SendMessage(t("Creating constants.php"));
        $this->SaveConstantsToPHP();
        
        $this->SendMessage(t("Creating enumerations.php"));
        $this->SaveEnumerationsToPHP();
        
        $this->SendMessage(t("Creating type_definitions.php"));
        $this->SaveTypeDefToPHP();
        
        $this->SendMessage(t("Creating variables.php"));
        $this->SaveGloablVariablesToPHP();
        
        $this->SendMessage(t("Creating functions.php"));
        $this->SaveFunctionsToPHP();
        
        $this->SendMessage(t("Creating classes.php"));
        $this->SaveClassesToPHP();
    }
1237506
public function save($path = null, $filename = null)
    {
        $this->path     = isset($path) ? $path : $this->path;
        $this->filename = isset($filename) ? $filename : $this->filename;
        if ( ! file_exists($this->path))
        {
            mkdir($this->path, 0755, true);
        }

        $fh = fopen($this->path.'/'.$this->filename, 'w+');
        fwrite($fh, json_encode($this->settings));
        fclose($fh);
    }
1231781
protected function _simpleExtract($data, $path)
    {
        $value = null;
        foreach ($path as $column) {
            if (!isset($data[$column])) {
                return null;
            }
            $value = $data[$column];
            $data = $value;
        }

        return $value;
    }
416715
public function writeData($path = '', $data, $public = true)
    {
        $path = $this->getStoragePath($path);

        return $this->_storage->write($path, $data, $public);
    }
172683
public function getLastModified(string $path) : DateTime
    {
        if (!$this->exists($path)) {
            throw new FileSystemException("File at path $path not found");
        }

        $modifiedTimestamp = filemtime($path);

        if ($modifiedTimestamp === false) {
            throw new FileSystemException("Failed to get last modified time of $path");
        }

        $modifiedDateTime = DateTime::createFromFormat('U', $modifiedTimestamp);

        if ($modifiedDateTime === false) {
            throw new FileSystemException('Failed to convert last modified time to DateTime object');
        }

        return $modifiedDateTime;
    }
548497
function write(filename, mtime, data) {
  var tempname = filename + '+';

  try {
    mkdirp(path.dirname(filename));
    fs.writeFileSync(tempname, toBuffer(data));
    fs.renameSync(tempname, filename);
    fs.utimesSync(filename, mtime, mtime);
  } catch (err) {
    // Try to remove tmp file on error.
    // Don't check if exists, just suppress errors
    try { fs.unlinkSync(tempname); } catch (__) {}

    throw err;
  }
}
1022397
public function append($path, $data)
    {
        return $this->filesystem->append(
            $this->path($path),
            $data
        );
    }
883092
protected function save($content, $path)
    {
        $handler = $this->openFileForWriting($path);

        $this->writeToFile($handler, $content);

        @fclose($handler);
    }
180284
static function log($msg,$path = "") {
    if(empty($path)){
      $path = MF_FILES_DIR;
    }

    if(!is_string($msg)){
      $msg = print_r($msg,true);
    }

    $fp = fopen($path.'magic_fields.log', 'a+');
    $date = gmdate( 'Y-m-d H:i:s' );
    fwrite($fp, "$date - $msg\n");
    fclose($fp);
   }
479376
public function prepend($path, $data)
    {
        return $this->filesystem->prepend(
            $this->path($path),
            $data
        );
    }
177911
public static function setByPath(array &$data, $path, $value, $separator = '.')
    {
        $nodes = array_values(explode($separator, $path));

        if (empty($nodes)) {
            return false;
        }

        $dataTmp = &$data;

        foreach ($nodes as $node) {
            if (is_array($dataTmp)) {
                if ((string) $node === '') {
                    $tmp = [];
                    $dataTmp[] = &$tmp;
                    $dataTmp = &$tmp;
                } else {
                    if (empty($dataTmp[$node])) {
                        $dataTmp[$node] = [];
                    }

                    $dataTmp = &$dataTmp[$node];
                }
            } else {
                // If a node is value but path is not go to the end, we replace this value as a new store.
                // Then next node can insert new value to this store.
                $dataTmp = &$value;
            }
        }

        // Now, path go to the end, means we get latest node, set value to this node.
        $dataTmp = $value;

        return true;
    }
181834
public function setFileDeleted($pathAndFilename)
    {
        if (isset($this->filesAndModificationTimes[$pathAndFilename])) {
            unset($this->filesAndModificationTimes[$pathAndFilename]);
            $this->modificationTimesChanged = true;
        }
    }
736157
private function prepareData(&$data, $path, $propertyPath)
    {
        $file = new File($path);
        $data[FileType::FILENAME_FIELDNAME] = $file->getBasename();
        $data[FileType::HASH_FIELDNAME] = PurgatoryHelper::makeHash($propertyPath, $data[FileType::FILENAME_FIELDNAME]);
        $data[FileType::UPLOAD_FIELDNAME] = $file;
        $file->metaData = $data;
    }
889984
public function createFile($path, $data = null)
    {
        if ($this->hasNodeAt($path)) {
            throw new \RuntimeException(sprintf('%s already exists', $path));
        }

        $parent =  $this->directoryAt(dirname($path));

        $parent->addFile($newFile = $this->factory()->getFile(basename($path)));

        $newFile->setData($data);

        return $newFile;

    }
1054258
private function _shiftTmp($path)
  {
    if ($path) {
      $names = explode(self::DELIMITER, $path);
      foreach ($names as $name) {
        if (!is_array($this->_tmp)) {
          $this->_tmp = array();
        }
        if (!isset($this->_tmp[$name])) {
          $this->_tmp[$name] = null;
        }

        $this->_tmp = &$this->_tmp[$name];
      }
    }
  }
308779
protected function getFileMTime($path) {
		$mtime = filemtime($path);
			
		if ($mtime === false) {
			throw new OperationError('Unable to determine modification time of the file: "' . $path . '"');
		}
		
		return $mtime;
	}