MakeDirectory() error on macOS

Report any Hollywood bugs here
Post Reply
User avatar
mrupp
Posts: 130
Joined: Sun Jan 31, 2021 7:44 pm
Location: Switzerland
Contact:

MakeDirectory() error on macOS

Post 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:
Image

But it fails on macOS Big Sur 11.6.2 with the following error:
Image

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

p-OS
Posts: 162
Joined: Mon Nov 01, 2010 11:56 pm

Re: MakeDirectory() error on macOS

Post by p-OS »

Just an idea...

try

Code: Select all

m_newDir$ = FullPath(m_currentDir$, "MakeDirectory")

User avatar
mrupp
Posts: 130
Joined: Sun Jan 31, 2021 7:44 pm
Location: Switzerland
Contact:

Re: MakeDirectory() error on macOS

Post 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?

p-OS
Posts: 162
Joined: Mon Nov 01, 2010 11:56 pm

Re: MakeDirectory() error on macOS

Post 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 ?

User avatar
airsoftsoftwair
Posts: 5040
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: MakeDirectory() error on macOS

Post 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.

User avatar
mrupp
Posts: 130
Joined: Sun Jan 31, 2021 7:44 pm
Location: Switzerland
Contact:

Re: MakeDirectory() error on macOS

Post 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?

User avatar
airsoftsoftwair
Posts: 5040
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: MakeDirectory() error on macOS

Post 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.

Post Reply