[Solved] Filesystem how do I/ bug report/ feature request


I use the file system to save variables to the hard drive. I used it earlier to an another project, even than I noticed this issue. now i have met it again and would like to clarify the situation. in principle it’s not a big error and it could also be that I’m doing something wrong or it’s a misunderstanding.

the problem is that the our filesystem does not know where the .exe file is. there is an expression, wich let me save in to the directory where the executable is. but it isn’t work. it seems the filesystem has no idea where are that directory.
I think it’s ok in preview mode, because the preview isn’t an .exe file. but after packaging and run from an .exe it still don’t work. I prepared an example project to speed up the inspection process. those who are interested, can download the necessary files from my GoogleDrive.
link: https://drive.google.com/drive/folders/14wP-G4dY1QsgmrYUWca5mafg4YTrcfor?usp=sharing
there is separate directories for the project files (to see the code) and the zipped package. I packed with the GD automatic online packaging service as a simple .zip, not as an installer!
may be this cause the problem but I have the reason to do this. I want to use Steam Auto Cloud and Steam isn’t really install the games in its own system, just download and copy the files to the user’s given Steam directory.
If this cause the problem, than treat this post as if it were a feature request. the Wiki wrote: “the folder where your game is being executed from”. so I have no idea where a program knows where is it executed from, but I can’t see any requirement written to this. and because of the above mentioned reasons, it would be great if it worked this way!

if this should work from the outset without installing the app, than treat this post as if it were a bug report.

if you find an error in the example, than treat this post as if it were a How do I? post.

and another feature request. there would be a nice and handy feature if in preview mode the the project file (*.JSON) count to the executable.

I can’t download your example project right now, however I cannot reproduce the issue you’re describing.

Here is a built example, using the ExecutablePath expression:

Here it is in preview (shows GD5’s install path instead):

Here are the events I"m using:

Edit: If you mean you’re trying to use Filesystem::ExecutablePath() for file system json storage, I bet that doesn’t work because it’s misnamed.

It is listed as:

However, it is not the executable folder. It is the full path to the game executable. So if you’re trying to save “mysave.json” at this path, it’s instead trying to save it as “c:\MyGamePath\MyGame.exemysave.json”, which won’t work.

Is this more what you’re experiencing?

1 Like

yes of course I use the “Filesystem::ExecutablePath()” because this is all I have. and it promised this will be the folder not the executable itself! now I understand what it is and how it work, but I will be happy to see this explanation in the Wiki! because it isn’t really helped me as usual.

so, how can I save my .JSON next to the executable? to its folder?

So I think you’re right that this is both a bug and a feature request.

@Bouh or @4ian
The current “This games executable folder” / FileSystem::ExecutablePath() is really “The full path to the executable” and the expression should probably be renamed to FileSystem::FullExecutablePath()

Users will still need a proper expression to the Executable Folder, so that likely still needs to be added.

@Gyuszko I had to do some digging (the expressions list at Expressions reference [GDevelop wiki] still has some old String expression names that don’t exist anymore, like StRFindFrom), but if you use the following instead of whereever you were going to use FileSystem::ExecutablePath(), this should get you the proper folder path:

SubStr(FileSystem::ExecutablePath(),0,StrFindLast(FileSystem::ExecutablePath(),FileSystem::PathDelimiter()) + 1)
1 Like

and also a how do I…? question, decause you had a solution :grin:

now it work fine, thank you very much!

1 Like

Reported here, if someting is missing feel free to add your note.

1 Like

it is perfect :+1: , thank you very much!

1 Like

It’s fixed by 4ian himself for b101.

  • Fix FileSystem::ExecutablePath description
  • Add FileSystem::ExecutableFolderPath expression to get the path to the folder where the game executable is located.
  • Add expressions FileSystem::DirectoryName, FileSystem::FileName and FileSystem::ExtensionName to extract part of a path.
  • Fix FileSystem::UserHomePath expression not working

thank you for him and for you too!

1 Like