MCPcopy Create free account
hub / github.com/PenguLoader/PenguLoader / generateHeader

Function generateHeader

plugins/vite.config.ts:73–93  ·  view source on GitHub ↗
(code: string, name: string, lineLength = 12)

Source from the content-addressed store, hash-verified

71});
72
73function generateHeader(code: string, name: string, lineLength = 12) {
74 const bytes = [...Buffer.from(code, 'utf-8')]
75 .map(c => '0x' + c.toString(16).padStart(2, '0'));
76
77 const formatted = Array<string>();
78 for (let i = 0; i < bytes.length; i += lineLength) {
79 const line = bytes.slice(i, i + lineLength).join(', ');
80 formatted.push(line);
81 }
82
83 return `#ifndef _${name.toUpperCase()}_H_
84#define _${name.toUpperCase()}_H_
85
86static const unsigned int _${name}_size = ${bytes.length};
87
88static const unsigned char _${name}[${bytes.length + 1}] = {
89 ${formatted.join(',\n ')}
90};
91
92#endif`
93}

Callers 1

closeBundleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected