I am building an editor with a web interface, but I thought it would be nice to be able to use it as a standalone desktop application. Since I heard this would be possible with Chrome packaged apps, I tried to make one. However, I am struggling with a seemingly basic thing: showing a file chooser and getting a file's real path on the disk. I need the real path because edited files have links to other files with relative paths, so it's not just a matter of getting the file content (which I could do with a simple HTML input).
First I had the problem with symbolic links to the package files. I avoided this by removing the links and copying the files by hand.
I tried to see if there was a file chooser in the dart chrome api. I didn't find one, so I decided to use the js package. It didn't work until I figured I had to include 'packages/js/dart_interop.js' in the main HTML file.
I was then able to call chrome.fileSystem.chooseEntry and display a file chooser. But I was not able to get the real file path afterwards:
- fileEntry.fullPath does not give the real URL, just a temporary path in the (virtual) fileSystem such as '/myfile.txt'
- chrome.runtime.getURL(fileEntry.fullPath) return a "chrome-extension://" URL
- getDisplayPath returns the real path, but it uses ~ shortcuts, making it useless to get the real URL
- fileEntry.toURL() returns nothing
Here is my code so far :
js.scoped(() {
var chrome =
js.context.chrome;
chrome.fileSystem.chooseEntry(js.map({'type': 'openFile'}),
new js.Callback.once((var fileEntry) {
}));
});
Is it even possible to get the real path or file:// URL ?