@@ -346,11 +346,21 @@ void MCAnswer::exec_ctxt(MCExecContext& ctxt)
346346 MCAutoStringRef t_initial_resolved;
347347 if (*t_initial != nil)
348348 {
349- // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
350- if (!MCS_resolvepath (*t_initial, &t_initial_resolved))
349+ // We only want to resolve the path if it is relative
350+ // (otherwise it will be created where LiveCode is located)
351+ if (MCStringContains (*t_initial, MCSTR (" /" ), kMCStringOptionCompareExact ))
351352 {
352- ctxt . LegacyThrow (EE_NO_MEMORY);
353- return ;
353+ // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
354+ if (!MCS_resolvepath (*t_initial, &t_initial_resolved))
355+ {
356+ ctxt . LegacyThrow (EE_NO_MEMORY);
357+ return ;
358+ }
359+ }
360+ else
361+ {
362+ // We simply take the initial path as it is
363+ t_initial_resolved = *t_initial;
354364 }
355365 }
356366
@@ -383,11 +393,21 @@ void MCAnswer::exec_ctxt(MCExecContext& ctxt)
383393 MCAutoStringRef t_initial_resolved;
384394 if (*t_initial != nil)
385395 {
386- // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
387- if (!MCS_resolvepath (*t_initial, &t_initial_resolved))
396+ // We only want to resolve the path if it is relative
397+ // (otherwise it will be created where LiveCode is located)
398+ if (MCStringContains (*t_initial, MCSTR (" /" ), kMCStringOptionCompareExact ))
388399 {
389- ctxt . LegacyThrow (EE_NO_MEMORY);
390- return ;
400+ // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
401+ if (!MCS_resolvepath (*t_initial, &t_initial_resolved))
402+ {
403+ ctxt . LegacyThrow (EE_NO_MEMORY);
404+ return ;
405+ }
406+ }
407+ else
408+ {
409+ // We simply take the initial path as it is
410+ t_initial_resolved = *t_initial;
391411 }
392412 }
393413
@@ -636,11 +656,18 @@ Exec_errors MCAnswer::exec_file(MCExecPoint& ep, const char *p_title)
636656 t_initial_resolved = nil;
637657
638658 if (!t_error && t_initial != nil)
639- {
640- // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
641- t_initial_resolved = MCS_get_canonical_path (t_initial);
642- if (nil == t_initial_resolved)
643- t_error == EE_NO_MEMORY;
659+ {
660+ // We only want to resolve the path if the path is relative (otherwise
661+ // it will be created at the current folder - which is /Applications)
662+ if (strchr (t_initial, ' /' ))
663+ {
664+ // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
665+ t_initial_resolved = MCS_get_canonical_path (t_initial);
666+ if (nil == t_initial_resolved)
667+ t_error = EE_NO_MEMORY;
668+ }
669+ else
670+ t_initial_resolved = strclone (t_initial);
644671 }
645672
646673 if (!t_error)
@@ -702,11 +729,18 @@ Exec_errors MCAnswer::exec_folder(MCExecPoint& ep, const char *p_title)
702729 t_initial_resolved = nil;
703730
704731 if (!t_error && t_initial != nil)
705- {
706- // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
707- t_initial_resolved = MCS_get_canonical_path (t_initial);
708- if (nil == t_initial_resolved)
709- t_error == EE_NO_MEMORY;
732+ {
733+ // We only want to resolve the path if the path is relative (otherwise
734+ // it will be created at the current folder - which is /Applications)
735+ if (strchr (t_initial, ' /' ))
736+ {
737+ // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
738+ t_initial_resolved = MCS_get_canonical_path (t_initial);
739+ if (nil == t_initial_resolved)
740+ t_error = EE_NO_MEMORY;
741+ }
742+ else
743+ t_initial_resolved = strclone (t_initial);
710744 }
711745
712746 if (!t_error)
0 commit comments