Forum

Writing Files using...
 
Notifications
Clear all

Writing Files using Javascript to wine File System in Emscripten  

  RSS

HamburgerTime
(@hamburgertime)
Active Member
Joined: 3 weeks ago
Posts: 6
07/01/2021 1:23 am  

Hello. I am currently working with your Emscripten project and I am kind of new to emscripten/development. My question what functions/objects should I be using to interact with the wine file system through javascript (not through wine).

Any help would be appreciated. I am doing stack traces on various points but this all seems pretty overwhelming to me so I thought I would reach out. 

Also, thank you for making this project it is quite impressive to me.


Quote
HamburgerTime
(@hamburgertime)
Active Member
Joined: 3 weeks ago
Posts: 6
07/01/2021 1:43 am  

Just to be clear writing/reading would be done after wine has been fully loaded


ReplyQuote
James Bryant
(@admin)
Member Admin
Joined: 3 years ago
Posts: 46
07/01/2021 1:53 am  

I'm not sure what you are trying to do.   Are you trying to modify/add/remove files that Wine or the app uses while it is running?

If you are editing a file while the file is not open, that might work.  But add/remove file while running will cause trouble because Boxedwine caches the file system entries in memory, so it knows which files are in which directory and won't query those directories again.

But it is fine to change the file system before launching Boxedwine.  You can also modify the file system zip for permanent changes.


ReplyQuote
HamburgerTime
(@hamburgertime)
Active Member
Joined: 3 weeks ago
Posts: 6
07/01/2021 2:36 am  

Hello, thanks for the reply and I am sorry for not being clear. Yes I am trying to modify files while Wine is running.

Editing a file would be sufficient for what I am trying to do, as I would not be writing to/accessing the file through javascript when the app in wine reads it.

So you are saying a way around it would be just to create dumby files at boot then write to them, given the system is not accessing these files while conducting a write? 

Thank you so much for the help I really appreciate it.

This post was modified 3 weeks ago by HamburgerTime

ReplyQuote
James Bryant
(@admin)
Member Admin
Joined: 3 years ago
Posts: 46
07/01/2021 2:43 am  

Yes, that could work, as long as the program doesn't need to see the size/date time change happen in real time.  If the program just periodically opens the file to re-read the contents, it should work.


ReplyQuote
HamburgerTime
(@hamburgertime)
Active Member
Joined: 3 weeks ago
Posts: 6
07/01/2021 2:54 am  

Yes that is exactly the functionality I need.  What API would I use to achieve this? Do I need to use the BrowserFS object? 


ReplyQuote
James Bryant
(@admin)
Member Admin
Joined: 3 years ago
Posts: 46
07/01/2021 3:11 am  

@Kevin worked on the BrowserFS, so I'm not sure how you would modify a running file system from javascript.   Maybe you might have some luck with the Emscripten forums since I don't think this isn't Boxedwine specific.

 

If you finish your project and its public, feel free to post a link here, I'm always curious how people might use this project.


ReplyQuote
HamburgerTime
(@hamburgertime)
Active Member
Joined: 3 weeks ago
Posts: 6
07/01/2021 3:15 am  

I was also playing with the local storage option, and noticed that newly created files were added to local storage. Would it be possible to simply create a file in wine then just modify it through local storage? The problem is I don't really understand how to interpret any meta data you attached. When I try to modify the contents it seems to crash the program, maybe I can just hack an interface together doing that? 

Thanks so much anyways. If this challenge doesn't defeat me I of course will post a link.


ReplyQuote
HamburgerTime
(@hamburgertime)
Active Member
Joined: 3 weeks ago
Posts: 6
07/01/2021 2:06 pm  

Just wanted to update that I got it working by decoding local storage data and modifying the Metadata, along with the file. 


ReplyQuote
Kevin O'Dwyer
(@kevin)
Active Member
Joined: 3 years ago
Posts: 17
07/01/2021 3:24 pm  

Hi,
Boxedwine already includes functionality to add (upload & drag and drop) as well as get files from JS.
To use set:
Config.showUploadDownload = true;
And
DEFAULT_AUTO_RUN = false;
in Boxedwine-shell.js
After adding files, click start button to launch.

The files are added to d:/

Files can be added using either the emscripten FS object or BrowserFS API.
Have a look at the createFile(), createFolder() functions. If you find something is missing or not working, I should be able to assist.

You can also use the app and overlay url parameters and even send a zip file dynamically to boxedwine as a base64 encoded string via app-payload and/or overlay-payload. See buildFlags.txt for instructions.


ReplyQuote
Share: