@@ -443,6 +443,48 @@ static bool MCDeployWriteCapsuleDefineStandaloneSections(const MCDeployParameter
443443 return t_success;
444444}
445445
446+ static bool MCDeployCapsuleDefineFromStackFile (MCDeployCapsuleRef p_self, MCStringRef p_filename, MCDeployFileRef p_file, bool p_mainstack)
447+ {
448+ MCAutoDataRef t_contents;
449+ if (!MCS_loadbinaryfile (p_filename, &t_contents))
450+ return false ;
451+
452+ IO_handle t_stream = nil;
453+ t_stream = MCS_fakeopen (MCDataGetBytePtr (*t_contents),MCDataGetLength (*t_contents));
454+
455+ if (t_stream == nil)
456+ return false ;
457+
458+ bool t_script_only = MCdispatcher -> streamstackisscriptonly (t_stream);
459+ MCS_close (t_stream);
460+
461+ MCCapsuleSectionType t_type;
462+ if (p_mainstack)
463+ {
464+ if (t_script_only)
465+ {
466+ t_type = kMCCapsuleSectionTypeScriptOnlyMainStack ;
467+ }
468+ else
469+ {
470+ t_type = kMCCapsuleSectionTypeMainStack ;
471+ }
472+ }
473+ else
474+ {
475+ if (t_script_only)
476+ {
477+ t_type = kMCCapsuleSectionTypeScriptOnlyAuxiliaryStack ;
478+ }
479+ else
480+ {
481+ t_type = kMCCapsuleSectionTypeAuxiliaryStack ;
482+ }
483+ }
484+
485+ return MCDeployCapsuleDefineFromFile (p_self, t_type, p_file);
486+ }
487+
446488// This method constructs and then writes out a capsule to the given output file.
447489// The capsule contents is derived from the deploy parameters structure.
448490// The offset in the file after writing is returned in x_offset.
@@ -514,7 +556,7 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
514556
515557 // Now we add the main stack
516558 if (t_success)
517- t_success = MCDeployCapsuleDefineFromFile (t_capsule, kMCCapsuleSectionTypeStack , t_stackfile);
559+ t_success = MCDeployCapsuleDefineFromStackFile (t_capsule, p_params . stackfile , t_stackfile, true );
518560
519561 // Now we add the auxillary stackfiles, if any
520562 MCAutoArray<MCDeployFileRef> t_aux_stackfiles;
@@ -528,7 +570,7 @@ bool MCDeployWriteCapsule(const MCDeployParameters& p_params, MCDeployFileRef p_
528570 if (t_success && !MCDeployFileOpen ((MCStringRef)t_val, kMCOpenFileModeRead , t_aux_stackfiles[i]))
529571 t_success = MCDeployThrow (kMCDeployErrorNoAuxStackfile );
530572 if (t_success)
531- t_success = MCDeployCapsuleDefineFromFile (t_capsule, kMCCapsuleSectionTypeAuxiliaryStack , t_aux_stackfiles[i]);
573+ t_success = MCDeployCapsuleDefineFromStackFile (t_capsule, (MCStringRef)t_val , t_aux_stackfiles[i], false );
532574 }
533575
534576 // AL-2015-02-10: [[ Standalone Inclusions ]] Add the resource mappings, if any.
0 commit comments