Page 1 of 1
MakeDirectory() error on macOS
Posted: Thu Feb 10, 2022 12:19 am
by mrupp
Hi there
Please check out the following example:
Code: Select all
@APPTITLE "MakeDirectory-Test"
SetFontColor(#LIME)
SetFontStyle(#ANTIALIAS)
SetFont(#SANS, 20)
m_currentDir$ = GetCurrentDirectory()
m_newDir$ = FullPath(m_currentDir$, "test")
SetMargins(20, 600)
NPrint("\nCurrent directory: " .. m_currentDir$)
NPrint("\nCreating new directory: " .. m_newDir$)
MakeDirectory(m_newDir$)
NPrint("\ndone")
Repeat
WaitEvent
Forever
This works on Windows and Amiga and creates the directory as expected:
But it fails on macOS Big Sur 11.6.2 with the following error:
Any clue why this might be?
I'm actually pretty sure that this was working a few macOS updates earlier, say last year or so...
Cheers,
Michael
Re: MakeDirectory() error on macOS
Posted: Thu Feb 10, 2022 7:56 pm
by p-OS
Just an idea...
try
Code: Select all
m_newDir$ = FullPath(m_currentDir$, "MakeDirectory")
Re: MakeDirectory() error on macOS
Posted: Thu Feb 10, 2022 8:56 pm
by mrupp
p-OS wrote: ↑Thu Feb 10, 2022 7:56 pm
Just an idea...
try
Code: Select all
m_newDir$ = FullPath(m_currentDir$, "MakeDirectory")
Sorry, I don’t get it, could you please elaborate why this should be working any different from my example? The only difference seems to be the name of the new folder, or what am I missing?
Re: MakeDirectory() error on macOS
Posted: Fri Feb 11, 2022 2:53 am
by p-OS
https://stackoverflow.com/questions/622 ... app-folder
There seem to exist some coding rules from Apple. Maybe newer OS Versions do enforce them ?
Re: MakeDirectory() error on macOS
Posted: Sun Feb 13, 2022 5:11 pm
by airsoftsoftwair
That's what I was thinking as well. I'm not sure if it's legit to write to the app bundle or if this needs special permissions.
Re: MakeDirectory() error on macOS
Posted: Mon Feb 14, 2022 2:40 pm
by mrupp
Now, this is interesting: The following code
works, the "test" subfolder is created in the "Ressources" folder in the app bundle:
Code: Select all
@APPTITLE "MakeDirectory-Test"
SetFontColor(#LIME)
SetFontStyle(#ANTIALIAS)
SetFont(#SANS, 20)
m_currentDir$ = GetCurrentDirectory()
;m_newDir$ = FullPath(m_currentDir$, "test")
m_newDir$ = "test"
SetMargins(20, 600)
NPrint("\nCurrent directory: " .. m_currentDir$)
NPrint("\nCreating new directory: " .. m_newDir$)
MakeDirectory(m_newDir$)
NPrint("\ndone")
Repeat
WaitEvent
Forever
So it seems to work, as long as not an absolute path pattern is used. Strange, it's the same thing, in the end. But it proofes that it's nothing to do with the app not having write permission to its "Ressource" folder, doesn't it?
Re: MakeDirectory() error on macOS
Posted: Mon Feb 14, 2022 8:42 pm
by airsoftsoftwair
mrupp wrote: ↑Mon Feb 14, 2022 2:40 pm
So it seems to work, as long as not an absolute path pattern is used. Strange, it's the same thing, in the end. But it proofes that it's nothing to do with the app not having write permission to its "Ressource" folder, doesn't it?
Still, writing to the app bundle folder sounds like a very bad idea to me. That's like trying to write to "C:\Program Files" on Windows which also isn't going to work. You should store files in the application support folder which you can get using
GetSystemInfo(). The path returned in the "AppData" table element is probably the right one.