Write a file header to the stream

@param string $name
@param int $uid
@param int $gid
@param int $perm
@param int $size
@param int $mtime
@param string $typeflag Set to '5' for directories
@throws ArchiveIOException
14042
protected function writeRawFileHeader($name, $uid, $gid, $perm, $size, $mtime, $typeflag = '')
    {
        // handle filename length restrictions
        $prefix  = '';
        $namelen = strlen($name);
        if ($namelen > 100) {
            $file = basename($name);
            $dir  = dirname($name);
            if (strlen($file) > 100 || strlen($dir) > 155) {
                // we're still too large, let's use GNU longlink
                $this->writeRawFileHeader('././@LongLink', 0, 0, 0, $namelen, 0, 'L');
                for ($s = 0; $s < $namelen; $s += 512) {
                    $this->writebytes(pack("a512", substr($name, $s, 512)));
                }
                $name = substr($name, 0, 100); // cut off name
            } else {
                // we're fine when splitting, use POSIX ustar
                $prefix = $dir;
                $name   = $file;
            }
        }

        // values are needed in octal
        $uid   = sprintf("%6s ", decoct($uid));
        $gid   = sprintf("%6s ", decoct($gid));
        $perm  = sprintf("%6s ", decoct($perm));
        $size  = sprintf("%11s ", decoct($size));
        $mtime = sprintf("%11s", decoct($mtime));

        $data_first = pack("a100a8a8a8a12A12", $name, $perm, $uid, $gid, $size, $mtime);
        $data_last  = pack("a1a100a6a2a32a32a8a8a155a12", $typeflag, '', 'ustar', '', '', '', '', '', $prefix, "");

        for ($i = 0, $chks = 0; $i < 148; $i++) {
            $chks += ord($data_first[$i]);
        }

        for ($i = 156, $chks += 256, $j = 0; $i < 512; $i++, $j++) {
            $chks += ord($data_last[$j]);
        }

        $this->writebytes($data_first);

        $chks = pack("a8", sprintf("%6s ", decoct($chks)));
        $this->writebytes($chks.$data_last);
    }
313507
public void writeDirect( byte[] b, int off, int len, int flags ) throws IOException {
        if( len <= 0 ) {
            return;
        }

        if( tmp == null ) {
            throw new IOException( "Bad file descriptor" );
        }
        ensureOpen();

        if( file.log.level >= 4 )
            file.log.println( "write: fid=" + file.fid + ",off=" + off + ",len=" + len );

        int w;
        do {
            w = len > writeSize ? writeSize : len;
            if( useNTSmbs ) {
                reqx.setParam( file.fid, fp, len - w, b, off, w );
if ((flags & 1) != 0) {
    reqx.setParam( file.fid, fp, len, b, off, w );
    reqx.writeMode = 0x8;
} else {
    reqx.writeMode = 0;
}
                file.send( reqx, rspx );
                fp += rspx.count;
                len -= rspx.count;
                off += rspx.count;
            } else {
                req.setParam( file.fid, fp, len - w, b, off, w );
                fp += rsp.count;
                len -= rsp.count;
                off += rsp.count;
                file.send( req, rsp );
            }
        } while( len > 0 );
    }
771828
private void writeName(String name)
		throws IOException
	{
		if(shouldOutputName())
		{
			out.write(TAG_KEY);
			writeStringNoTag(name);
		}
	}
283285
public function privWriteCentralFileHeader(&$p_header)
    {
        $v_result=1;

        // TBC
        //for(reset($p_header); $key = key($p_header); next($p_header)) {
        //}

        // ----- Transform UNIX mtime to DOS format mdate/mtime
        $v_date = getdate($p_header['mtime']);
        $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
        $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];


        // ----- Packed data
        $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, $p_header['version'], $p_header['version_extracted'], $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], $p_header['compressed_size'], $p_header['size'], strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']);

        // ----- Write the 42 bytes of the header in the zip file
        fputs($this->zip_fd, $v_binary_data, 46);

        // ----- Write the variable fields
        if (strlen($p_header['stored_filename']) != 0) {
            fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
        }
        if ($p_header['extra_len'] != 0) {
            fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
        }
        if ($p_header['comment_len'] != 0) {
            fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
        }

        // ----- Return
        return $v_result;
    }
1092062
static function write($name, $config, $comment = null, $pretty = true)
    {
        $fp = fopen(DIR_CONFIG.$name.'.php', 'w');
        fwrite($fp, self::generate($config, $comment, $pretty));
        fclose($fp);
    }
1002666
public function writeImageHeader($width, $height, $colorType) 
    {
        $this->buffer->startChunk("IHDR");
        $this->buffer->writeUInt32BE($width);
        $this->buffer->writeUInt32BE($height);
        $this->buffer->writeUInt8(8); // Bit depth
        $this->buffer->writeUInt8($colorType);
        $this->buffer->writeUInt8(0); // Compression
        $this->buffer->writeUInt8(0); // Filter
        $this->buffer->writeUInt8(0); // Interlace
        $this->buffer->endChunk();
    }
1304701
function _write_header($fd)
	{
		$buf = pack('a3CiiIfa12', XDB_TAGNAME, $this->version,
			$this->hash_base, $this->hash_prime, 0, XDB_FLOAT_CHECK, '');

		fseek($fd, 0, SEEK_SET);
		fwrite($fd, $buf, 32);
	}
856051
final void writeHeader()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        "writeHeader");

        // Write the header.
        sharedBuffer.clear();
        sharedBuffer.putInt(version);
        for (int i = 0; i < signature.length(); i++)
            sharedBuffer.putChar(signature.charAt(i));
        sharedBuffer.putLong(objectStoreIdentifier);
        sharedBuffer.putLong(((Directory.Node) directory.root).byteAddress);
        sharedBuffer.putLong(((Directory.Node) directory.root).length);
        sharedBuffer.putInt(directory.getMinimumNodeSize());
        if (freeSpaceStoreArea == null) {
            sharedBuffer.putLong(0);
            sharedBuffer.putLong(0);
        } else {
            sharedBuffer.putLong(freeSpaceStoreArea.byteAddress);
            sharedBuffer.putLong(freeSpaceStoreArea.length);
        }
        sharedBuffer.putLong((long) freeSpaceByLength.size());
        sharedBuffer.putLong(sequenceNumber);
        sharedBuffer.putLong(storeFileSizeUsed);
        sharedBuffer.putLong(minimumStoreFileSize);
        sharedBuffer.putLong(maximumStoreFileSize);
        sharedBuffer.putInt(cachedManagedObjectsSize);

        sharedBuffer.flip();
        writeBuffer(sharedBuffer,
                    0);

        // Write the header twice.
        sharedBuffer.flip();
        writeBuffer(sharedBuffer,
                    pageSize);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       "writeHeader"
                            );
    }
453516
def write_file(self, name, path=None):
        """"""

        if path is None:
            path = name

        self.zf.write(path, name)
56292
protected function writeMigration($name, $extension, $table, $create)
    {
        $path = $this->creator->create($name, $extension, $table, $create);

        $file = pathinfo($path, PATHINFO_FILENAME);

        $this->info("Created migration: $file");
    }
1282077
private void writeHeader(WritableByteChannel channel) throws IOException
    {
        //write descriptive text
        MatFileHeader header = MatFileHeader.createHeader();
        char[] dest = new char[116];
        char[] src = header.getDescription().toCharArray();
        System.arraycopy(src, 0, dest, 0, src.length);

        byte[] endianIndicator = header.getEndianIndicator();

        ByteBuffer buf = ByteBuffer.allocateDirect(dest.length * 2 /* Char size */ + 2 + endianIndicator.length);

        for ( int i = 0; i < dest.length; i++ )
        {
            buf.put( (byte)dest[i] );
        }
        //write subsyst data offset
        buf.position( buf.position() + 8);

        //write version
        int version = header.getVersion();
        buf.put( (byte)(version >> 8) );
        buf.put( (byte)version );

        buf.put( endianIndicator );

        buf.flip();
        channel.write(buf);
    }
443569
public function dumpImageMap(
        $Name = "pChart",
        $StorageMode = IMAGE_MAP_STORAGE_SESSION,
        $UniqueID = "imageMap",
        $StorageFolder = "tmp"
    ) {
        $this->ImageMapIndex = $Name;
        $this->ImageMapStorageMode = $StorageMode;

        if ($this->ImageMapStorageMode == IMAGE_MAP_STORAGE_SESSION) {
            if (!isset($_SESSION)) {
                session_start();
            }
            if ($_SESSION[$Name] != null) {
                foreach ($_SESSION[$Name] as $Key => $Params) {
                    echo $Params[0] . IMAGE_MAP_DELIMITER . $Params[1]
                    . IMAGE_MAP_DELIMITER . $Params[2] . IMAGE_MAP_DELIMITER
                    . $Params[3] . IMAGE_MAP_DELIMITER . $Params[4] . "\r\n";
                }
            }
        } elseif ($this->ImageMapStorageMode == IMAGE_MAP_STORAGE_FILE) {
            if (file_exists($StorageFolder . "/" . $UniqueID . ".map")) {
                $Handle = @fopen($StorageFolder . "/" . $UniqueID . ".map", "r");
                if ($Handle) {
                    while (($Buffer = fgets($Handle, 4096)) !== false) {
                        echo $Buffer;
                    }
                }
                fclose($Handle);

                if ($this->ImageMapAutoDelete) {
                    unlink($StorageFolder . "/" . $UniqueID . ".map");
                }
            }
        }

        /* When the image map is returned to the client, the script ends */
        exit();
    }
311407
private function load(string $type, string $slug, string $name = ''): string
    {
        $slug = \ltrim($slug, '/');
        $slug = \rtrim($slug, '.php');

        $this->doAction($type, $slug, $name);

        $slug = $this->rewriteSlug($type, $slug);
        $rel_dir = $this->utilities->fileSystem->relativeDir();

        $templates = [];

        if ($name) {
            $templates[] = "{$slug}-{$name}.php";

            if ($rel_dir) {
                $templates[] = "{$rel_dir}/{$slug}-{$name}.php";
            }
        }

        $templates[] = "{$slug}.php";

        if ($rel_dir) {
            $templates[] = "{$rel_dir}/{$slug}.php";
        }

        return \locate_template($templates, true, false);
    }
446905
public static void writeRAMFiles(DataOutput out, RAMDirectory dir,
      String[] names) throws IOException {
    out.writeInt(names.length);

    for (int i = 0; i < names.length; i++) {
      Text.writeString(out, names[i]);
      long length = dir.fileLength(names[i]);
      out.writeLong(length);

      if (length > 0) {
        // can we avoid the extra copy?
        IndexInput input = null;
        try {
          input = dir.openInput(names[i], BUFFER_SIZE);

          int position = 0;
          byte[] buffer = new byte[BUFFER_SIZE];

          while (position < length) {
            int len =
                position + BUFFER_SIZE <= length ? BUFFER_SIZE
                    : (int) (length - position);
            input.readBytes(buffer, 0, len);
            out.write(buffer, 0, len);
            position += len;
          }
        } finally {
          if (input != null) {
            input.close();
          }
        }
      }
    }
  }
721283
public synchronized void writeHeader(long timestamp) throws IOException {
		if (writer == null && headerBytes != null) {
			writer = createNewWriter(manager.startNewFile(timestamp));
			writer.write(headerBytes);
			manager.notifyOfFileAction(LogEventListener.EVENTTYPEROLL) ;
		}
	}
37587
public static function mark($name)
    {
        $LOG = array('type' => 'BMARK',
            'message' => (!is_null($name) ? $name : ''),
            'logFile' => '',
            'logLine' => '',
            'context' => '',
            'runtime' => round(self::getRelativeTime(), 4),);

        self::$Logs[] = $LOG;
    }
420652
public void writeFile(CmsFile file, String name) throws IOException {

        if (m_isExportAsFiles) {
            writeFile2Rfs(file, name);
        } else {
            writeFile2Zip(file, name);
        }
    }