Writing to ˜/Library/Application Support/

Pierrou

Active member
Joined
Jul 6, 2017
Messages
198
Hi there
I'm stuck for months with the same problem I really don't know what to do.
I'd like to store some prefs/files (images) in some directory for my app and the dirs and files are just not created when I try, but, again, I have no clue about how to do it on MacOS (High Sierra)
If I use
Code:
#GLFW_APP_LABEL="SyntagmaToons"
#GLFW_APP_PUBLISHER="SiliceEtSynapses"
A directory SiliceEtSynapses is created as well as a SyntagmaToons subdirectory in ˜/Library/Application Support/ but then I can't get to write anything inside it.
whether I use
Code:
"/Users/"+GetEnv("USER")+"/Library/Application Support/SiliceEtSynapses/SyntagmaToons/"
or
Code:
"cerberus://internal/"
as a path to create stuff using CreateDir for example.

What am I doing wrong?
Thanks if you can help before I go crazy!

EDIT : Using
Code:
CopyFile("cerberus://data/image.png","cerberus://internal/copiedimage.png")
does copy the image inside /Library/Application Support/SiliceEtSynapses/SyntagmaToons/ but using CreateDir for example does nothing

EDIT 2 : OK in fact I can create a text file and append some text to it inside cerberus://internal/ but I can't create /or copy/ any folder to that directory why is it so?
 
Last edited:

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
586
I tried the example from the helpfile for the filesystem module and couldn't create folders either. I am on Big Sur.
Sorry, but my knowledge with macOs is very limited, so I can't help with that.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,988
Looks like a bug to me or at least a missing feature. Will try to add it.
 

Pierrou

Active member
Joined
Jul 6, 2017
Messages
198
Thanks a lot to both of you!
I can use a workaround avoiding to create folders but I guess it would be nice if CreateDir/CopyDir could work on MacOS too.
(EDIT : this is the last issue preventing me from releasing a Mac version of my latest app so more sales [and more trouble] ahead)
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,988
Btw. "cerberus://internal/" get translated to


String( getenv( "HOME" ) )+"/Library/Application Support";

on Apple. I think that differs from "/Users/"+GetEnv("USER")+"/Library/Application Support/"
 

Pierrou

Active member
Joined
Jul 6, 2017
Messages
198
Thanks for that info, I switched to using "cerberus://internal" everywhere anyway
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,988
Nevermind, I think you reach to the same place. Anyway, there was a bug inside CreateDir.

In modules/brl/filesystem.cxs please replace the CreateDir function with this one:

Code:
Function CreateDir:Bool( path:String )
    Local _ret:Bool = False
    path = FixPath(path).Replace("\","/")
'Print("++ "+path)
    Local _dirs:= path.Split("/")
    Local _curDir:=""
If path.StartsWith("/") Then _curDir = "/"
    For Local _dir :=Eachin _dirs
        If _dir.Length()= 0 Continue
        _curDir += _dir
        If FileType(_curDir)<>FILETYPE_DIR
            _ret = BBFileSystem.CreateDir( FixPath( _curDir ) )
            'Print(">> "+FixPath( _curDir ))
        'Else
            'Print(_curDir)
        Endif
        _curDir += "/"
    Next
    Return _ret
End
 
Top Bottom