@@ -344,11 +344,21 @@ void MCAnswer::exec_ctxt(MCExecContext& ctxt)
344344 MCAutoStringRef t_initial_resolved;
345345 if (*t_initial != nil)
346346 {
347- // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
348- if (!MCS_resolvepath (*t_initial, &t_initial_resolved))
347+ // We only want to resolve the path if it is relative
348+ // (otherwise it will be created where LiveCode is located)
349+ if (MCStringContains (*t_initial, MCSTR (" /" ), kMCStringOptionCompareExact ))
349350 {
350- ctxt . LegacyThrow (EE_NO_MEMORY );
351- return ;
351+ // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
352+ if (!MCS_resolvepath (*t_initial, &t_initial_resolved))
353+ {
354+ ctxt . LegacyThrow (EE_NO_MEMORY );
355+ return ;
356+ }
357+ }
358+ else
359+ {
360+ // We simply take the initial path as it is
361+ t_initial_resolved = *t_initial;
352362 }
353363 }
354364
@@ -381,11 +391,21 @@ void MCAnswer::exec_ctxt(MCExecContext& ctxt)
381391 MCAutoStringRef t_initial_resolved;
382392 if (*t_initial != nil)
383393 {
384- // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
385- if (!MCS_resolvepath (*t_initial, &t_initial_resolved))
394+ // We only want to resolve the path if it is relative
395+ // (otherwise it will be created where LiveCode is located)
396+ if (MCStringContains (*t_initial, MCSTR (" /" ), kMCStringOptionCompareExact ))
386397 {
387- ctxt . LegacyThrow (EE_NO_MEMORY );
388- return ;
398+ // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
399+ if (!MCS_resolvepath (*t_initial, &t_initial_resolved))
400+ {
401+ ctxt . LegacyThrow (EE_NO_MEMORY );
402+ return ;
403+ }
404+ }
405+ else
406+ {
407+ // We simply take the initial path as it is
408+ t_initial_resolved = *t_initial;
389409 }
390410 }
391411
@@ -634,11 +654,18 @@ Exec_errors MCAnswer::exec_file(MCExecPoint& ep, const char *p_title)
634654 t_initial_resolved = nil;
635655
636656 if (!t_error && t_initial != nil)
637- {
638- // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
639- t_initial_resolved = MCS_get_canonical_path (t_initial);
640- if (nil == t_initial_resolved)
641- t_error == EE_NO_MEMORY ;
657+ {
658+ // We only want to resolve the path if the path is relative (otherwise
659+ // it will be created at the current folder - which is /Applications)
660+ if (strchr (t_initial, ' /' ))
661+ {
662+ // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
663+ t_initial_resolved = MCS_get_canonical_path (t_initial);
664+ if (nil == t_initial_resolved)
665+ t_error = EE_NO_MEMORY ;
666+ }
667+ else
668+ t_initial_resolved = strclone (t_initial);
642669 }
643670
644671 if (!t_error)
@@ -700,11 +727,18 @@ Exec_errors MCAnswer::exec_folder(MCExecPoint& ep, const char *p_title)
700727 t_initial_resolved = nil;
701728
702729 if (!t_error && t_initial != nil)
703- {
704- // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
705- t_initial_resolved = MCS_get_canonical_path (t_initial);
706- if (nil == t_initial_resolved)
707- t_error == EE_NO_MEMORY ;
730+ {
731+ // We only want to resolve the path if the path is relative (otherwise
732+ // it will be created at the current folder - which is /Applications)
733+ if (strchr (t_initial, ' /' ))
734+ {
735+ // IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
736+ t_initial_resolved = MCS_get_canonical_path (t_initial);
737+ if (nil == t_initial_resolved)
738+ t_error = EE_NO_MEMORY ;
739+ }
740+ else
741+ t_initial_resolved = strclone (t_initial);
708742 }
709743
710744 if (!t_error)
0 commit comments