Fixed on GIT CreateDir() doesn't work like suggested in the docs

Martin

Active member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Joined
Jun 19, 2017
Messages
320
As the title says. Docs say that using
Code:
CreateDir("cerberus://internal/logs")
a directory should be created.

Actually you have to do:
Code:
CreateDir("internal/logs")

At least for Windows...
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
552
You are talking about CreateDir from module filesystem and not os, right?
I guess I can look into this at the weekend. To me it looks rather like a bug in functionality than in documentation.
If CreateDir("internal/logs") works, this would either mean that the working directory is the app folder or relative paths don't work properly.
Both is not congruent with the multiplatform way of CX .
 

Martin

Active member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Joined
Jun 19, 2017
Messages
320
Oh yes I mean the one from brl.filesystem.

Same is true for DeleteFile and CopyFile by the way. Haven't checked the others. And yes it seems to work pretty well using the app folder as working directory.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,845
Quick fix:
Replace CreateDir in brl.filesystem with this version:
code_language.cerberus:
Function CreateDir:Bool( path:String )
    Local _ret:Bool = False
    'path = path.Replace("\","/")
    path = FixPath( path )
    Local _dirs:= path.Split("/")
    Local _curDir:=""
    For Local _dir :=Eachin _dirs
        If _dir.Length()= 0 Continue
        _curDir += _dir
        If FileType(_curDir)<>FILETYPE_DIR
            _ret = BBFileSystem.CreateDir( FixPath( _curDir ) )
        Endif
        _curDir += "/"
    Next
    Return _ret
End

That should do the trick with creating directories with cerberus://internal.
Regarding CopyFile... with CopyFile make sure the target path already exists. Or would you expect to create the path too, if it doesn't?

And with DeleteFile... you say it doesn't work? Works fine here.

If you have set #GLFW_APP_LABEL and optional #GLFW_APP_PUBLISHER then the internal directory is located inside your user directory in APPDATA/Roaming/....
For an example...

1607713169594.png
 

Martin

Active member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Joined
Jun 19, 2017
Messages
320
Ah, of course the %APPDATA% path. Haven't thought of that. So on Windows it should be all put there right? As you usually shouldn't store any stuff outside that appdata path anymore?
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
2,845
It does that only if you have set #GLFW_APP_LABEL. If not, it will use the internal folder next to your app.
 

Martin

Active member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Joined
Jun 19, 2017
Messages
320
Ok everything works fine, thanks! :)

Regarding CopyFile... with CopyFile make sure the target path already exists. Or would you expect to create the path too, if it doesn't?

No all good, don't need that!
 
Top Bottom