How to use File class with HTML 5 export ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CplBator
:warning: Old Version Published before Godot 3 was released.

i try to open file with File class : http://docs.godotengine.org/en/latest/classes/class_file.html

it’s work fine in the editor project, but, when i export my project to HTML 5 on my rpi2 server , the is_open() method return false.

Thanks.

:bust_in_silhouette: Reply From: Hinsbart

Are you using user:// for the path? I think that’s the only path supported for file operations on the html5 export (it uses the browsers persistent storage).

Also I’ve read that you might need to deploy to an actual server for this to work, but it seems you got that part covered.

Thanks for your answer, i think is the way, but the documentation is not clear for this point. (http://docs.godotengine.org/en/latest/tutorials/engine/data_paths.html)
they say , “in windows, use “APPDATA/name” for the user directory, and for linux an hidden folder located in user directory " ~/.Name” " , but , i use godot on win7 for now, where is located in the hard disk the APPDATA folder ?

i have trying this link : Redirecting

i have tried to create hidden folder to my server in my home directory ( dont work )
and i have tried to create a folder inside %appdata% on windows 7 , don’t work too.

Thanks in advance.

CplBator | 2016-02-23 17:01

You don’t have to create that directory yourself. It should be created the first time you open up a project. Inside the engine you just access it with “user://”.

Sadly I don’t have access to a windows machine right now, so I can’t say where this folder is.
But you can print this easily with OS.get_data_dir() :slight_smile:

Hinsbart | 2016-02-23 17:13

Thank you, the OS.get_data_dir() is the way !

in windows :
C:\Users\NAME\AppData\Roaming\Godot\app_userdata\PROJECT_NAME

i will apply this method to locate the same folder on linux now.

Edit :

On Linux ( my server debian PI2 ) , the OS.get_data_dir() method return userfs/

CplBator | 2016-02-23 17:23