Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions source/PhpBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ export class PhpBase extends EventTarget
php.FS.mkdir('/preload');
}

// Make sure folder structure exists before preloading files
files.forEach(fileDef => {
const segments = fileDef.parent.split('/');
let currentPath = '';
for (const segment of segments) {
if (!segment) continue;

currentPath += segment + '/';
if (!php.FS.analyzePath(currentPath).exists) {
console.log("create dir " + currentPath);
php.FS.mkdir(currentPath);
}
}
});

await Promise.all(files.concat(extraFiles).map(
fileDef => new Promise(accept => php.FS.createPreloadedFile(
fileDef.parent,
Expand Down