mirror of https://gitlab.com/nakst/essence
prefix internal embed files
This commit is contained in:
parent
6c106d1a1f
commit
1cdbaacdc3
|
@ -1167,10 +1167,10 @@ extern "C" void _start(EsProcessStartupInformation *_startupInformation) {
|
||||||
theming.scale = api.systemConstants[ES_SYSTEM_CONSTANT_UI_SCALE] / 100.0f;
|
theming.scale = api.systemConstants[ES_SYSTEM_CONSTANT_UI_SCALE] / 100.0f;
|
||||||
|
|
||||||
size_t fileBytes;
|
size_t fileBytes;
|
||||||
const void *file = EsEmbeddedFileGet(EsLiteral("Theme.dat"), &fileBytes);
|
const void *file = EsEmbeddedFileGet(EsLiteral("$Desktop/Theme.dat"), &fileBytes);
|
||||||
EsAssert(ThemeLoadData(file, fileBytes));
|
EsAssert(ThemeLoadData(file, fileBytes));
|
||||||
|
|
||||||
iconManagement.standardPack = (const uint8_t *) EsEmbeddedFileGet(EsLiteral("Icons.dat"), &iconManagement.standardPackSize);
|
iconManagement.standardPack = (const uint8_t *) EsEmbeddedFileGet(EsLiteral("$Desktop/Icons.dat"), &iconManagement.standardPackSize);
|
||||||
|
|
||||||
theming.cursors.width = ES_THEME_CURSORS_WIDTH;
|
theming.cursors.width = ES_THEME_CURSORS_WIDTH;
|
||||||
theming.cursors.height = ES_THEME_CURSORS_HEIGHT;
|
theming.cursors.height = ES_THEME_CURSORS_HEIGHT;
|
||||||
|
@ -1498,30 +1498,27 @@ void EsInstanceSetActiveUndoManager(EsInstance *_instance, EsUndoManager *manage
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *EsEmbeddedFileGet(const char *_name, ptrdiff_t nameBytes, size_t *byteCount) {
|
const void *EsEmbeddedFileGet(const char *_name, ptrdiff_t nameBytes, size_t *byteCount) {
|
||||||
// TODO It's probably a bad idea to let applications load embedded files from Desktop.
|
if (nameBytes == -1) {
|
||||||
|
nameBytes = EsCStringLength(_name);
|
||||||
uint64_t name = CalculateCRC64(_name, nameBytes == -1 ? EsCStringLength(_name) : nameBytes);
|
}
|
||||||
|
|
||||||
for (uintptr_t i = 0; i < 2; i++) {
|
const BundleHeader *header = (const BundleHeader *) BUNDLE_FILE_MAP_ADDRESS;
|
||||||
if (i == 0 && (api.startupInformation->isDesktop || !api.startupInformation->isBundle)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BundleHeader *header = (const BundleHeader *) (i ? BUNDLE_FILE_DESKTOP_MAP_ADDRESS : BUNDLE_FILE_MAP_ADDRESS);
|
if (nameBytes > 9 && 0 == EsMemoryCompare(_name, "$Desktop/", 9)) {
|
||||||
const BundleFile *files = (const BundleFile *) (header + 1);
|
header = (const BundleHeader *) BUNDLE_FILE_DESKTOP_MAP_ADDRESS;
|
||||||
|
_name += 9, nameBytes -= 9;
|
||||||
|
}
|
||||||
|
|
||||||
if (header->signature != BUNDLE_SIGNATURE) {
|
const BundleFile *files = (const BundleFile *) (header + 1);
|
||||||
return nullptr;
|
uint64_t name = CalculateCRC64(_name, nameBytes);
|
||||||
}
|
|
||||||
|
|
||||||
for (uintptr_t i = 0; i < header->fileCount; i++) {
|
for (uintptr_t i = 0; i < header->fileCount; i++) {
|
||||||
if (files[i].nameCRC64 == name) {
|
if (files[i].nameCRC64 == name) {
|
||||||
if (byteCount) {
|
if (byteCount) {
|
||||||
*byteCount = files[i].bytes;
|
*byteCount = files[i].bytes;
|
||||||
}
|
|
||||||
|
|
||||||
return (const uint8_t *) header + files[i].offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (const uint8_t *) header + files[i].offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ EsError KLoadELF(KNode *node, KLoadedExecutable *executable) {
|
||||||
// Look for the executable in the bundle.
|
// Look for the executable in the bundle.
|
||||||
|
|
||||||
#ifdef ARCH_X86_64
|
#ifdef ARCH_X86_64
|
||||||
uint64_t name = CalculateCRC64(EsLiteral("Executable (x86_64)"));
|
uint64_t name = CalculateCRC64(EsLiteral("$Executables/x86_64"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BundleFile *files = (BundleFile *) ((BundleHeader *) header.mapAddress + 1);
|
BundleFile *files = (BundleFile *) ((BundleHeader *) header.mapAddress + 1);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// TODO Prevent Meltdown/Spectre exploits.
|
// TODO Prevent Meltdown/Spectre exploits.
|
||||||
// TODO Kernel debugger.
|
// TODO Kernel debugger.
|
||||||
// TODO Passing data to userspace - zeroing padding bits of structures.
|
// TODO Passing data to userspace - zeroing padding bits of structures.
|
||||||
|
// TODO Restoring all registers after system call.
|
||||||
// TODO Remove file extensions?
|
// TODO Remove file extensions?
|
||||||
// TODO Thread-local variables for native applications (already working under the POSIX subsystem).
|
// TODO Thread-local variables for native applications (already working under the POSIX subsystem).
|
||||||
|
|
||||||
|
|
|
@ -567,7 +567,7 @@ void BuildDesktop(Application *application) {
|
||||||
ADD_BUNDLE_INPUT("res/Themes/Theme.dat", "Theme.dat", 16);
|
ADD_BUNDLE_INPUT("res/Themes/Theme.dat", "Theme.dat", 16);
|
||||||
ADD_BUNDLE_INPUT("res/Themes/elementary Icons.dat", "Icons.dat", 16);
|
ADD_BUNDLE_INPUT("res/Themes/elementary Icons.dat", "Icons.dat", 16);
|
||||||
ADD_BUNDLE_INPUT("res/Themes/elementary Icons License.txt", "Icons License.txt", 16);
|
ADD_BUNDLE_INPUT("res/Themes/elementary Icons License.txt", "Icons License.txt", 16);
|
||||||
ADD_BUNDLE_INPUT("bin/Desktop.no_symbols", "Executable (x86_64)", 0x1000);
|
ADD_BUNDLE_INPUT("bin/Desktop.no_symbols", "$Executables/x86_64", 0x1000);
|
||||||
|
|
||||||
MakeBundle("root/Essence/Desktop.esx", application->bundleInputFiles, arrlenu(application->bundleInputFiles), 0);
|
MakeBundle("root/Essence/Desktop.esx", application->bundleInputFiles, arrlenu(application->bundleInputFiles), 0);
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,7 @@ void BuildApplication(Application *application) {
|
||||||
ArgString(applicationLinkFlags), "-T", linkerScript);
|
ArgString(applicationLinkFlags), "-T", linkerScript);
|
||||||
ExecuteForApp(application, toolchainStrip, "-o", strippedFile, "--strip-all", symbolFile);
|
ExecuteForApp(application, toolchainStrip, "-o", strippedFile, "--strip-all", symbolFile);
|
||||||
|
|
||||||
ADD_BUNDLE_INPUT(strippedFile, "Executable (x86_64)", 0x1000);
|
ADD_BUNDLE_INPUT(strippedFile, "$Executables/x86_64", 0x1000);
|
||||||
|
|
||||||
// Convert any files for the bundle marked with a '!'.
|
// Convert any files for the bundle marked with a '!'.
|
||||||
|
|
||||||
|
@ -853,7 +853,7 @@ void OutputSystemConfiguration() {
|
||||||
FilePrintFormat(file, "%s=|Fonts:/%.*s.dat\n", fontLines[i].key, (int) fontLines[i].valueBytes - 4, fontLines[i].value);
|
FilePrintFormat(file, "%s=|Fonts:/%.*s.dat\n", fontLines[i].key, (int) fontLines[i].valueBytes - 4, fontLines[i].value);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
FilePrintFormat(file, "%s=:%s\n", fontLines[i].key, fontLines[i].value);
|
FilePrintFormat(file, "%s=:$Desktop/%s\n", fontLines[i].key, fontLines[i].value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t bytes = EsINIFormat(fontLines + i, buffer, sizeof(buffer));
|
size_t bytes = EsINIFormat(fontLines + i, buffer, sizeof(buffer));
|
||||||
|
|
Loading…
Reference in New Issue