Hi Anshul, On Tue, 24 Mar 2020 04:04:23 -0700 (PDT) anshul mahajan <[email protected]> wrote:
> Hi All, > > I have got a test-app which is used for testing our application. When we > run test-app we create output.xml for each of the test-cases which were > executed. > Since in emscripten we can't create a new file on local file system i.e on > local machine. On digging I come around IDBFS file system support in > emscripten : by using this file system we can mock writing new file to > local file system where the actual file are written to indexed db. > > So for testing I have created POC attached is the cpp file : untitled.cpp > Calling mkdir() seems to help, see: https://www.shlomifish.org/Files/files/dirs/stdio-test-2del/2del/filetest.html Sources: * https://www.shlomifish.org/Files/files/dirs/stdio-test-2del/2del/untitled.cpp * https://www.shlomifish.org/Files/files/dirs/stdio-test-2del/2del/build.bash Regards, Shlomi > Command used : > > emcc untitled.cpp -o filetest.html -lidbfs.js -s FETCH=1 -s > FORCE_FILESYSTEM=1 -s NO_EXIT_RUNTIME=1 > > Let me just brief you about the code : > > 1) I have mounted following directory in IDBFS : "working1" > > EM_ASM( > > FS.mkdir('/working1'); > > FS.mount(IDBFS, {}, '/working1'); > > > > FS.syncfs(true, function (err) { > > assert(!err); > > }); > > ); > > > 2) call util_create func which in turn call test func. In test func I am > creating new file "/working1/twrite.txt" *"/working1/**working2/* > *twrite1.txt"* and "/working1/twrite2.txt" > > 3) call sync_idbfs() which is used to persists changes in indexed db i.e. > working1 > > > > Error : when call read_fs(func used for reading file) on file :*"/working1/* > *working2/**twrite1.txt" ->* I am getting following error : stdio streams > had content in them that was not flushed. you should set EXIT_RUNTIME to 1 > (see the FAQ), or make sure to emit a newline when you printf etc. > > please note that in all my printf statement I have got \n and also the flag > is passed while compiling. > > > And also, I am not able to see following file > *"/working1/**working2/**twrite1.txt" in indexed db of browser but I am able > to see following file twrite.txt and twrite2.txt.* > > *So my question is that , has anyone created a sub directory using IDBFS > file system. And pointer on the same i.e what all thing I can try.* > > Please note that I have unsuccessfully tried following thing : > 1) before mounting creating sub directory as well i.e. FS.mkdir('/working1'); > and FS.mkdir('/working1/working2'); > > 2) before creating new file in sub directory i,e > FS.mkdir('/working1/working2'); and creating new file in sub dir. > > Regards, > > Anshul > > > > > -- Shlomi Fish https://www.shlomifish.org/ https://www.shlomifish.org/humour/bits/Can-I-SCO-Now/ - “Can I SCO Now?” Academic Politics are so vicious precisely because the stakes are so low. — https://quoteinvestigator.com/2013/08/18/acad-politics/ Please reply to list if it's a mailing list post - http://shlom.in/reply . -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/20200327112520.74fe0e15%40telaviv1.shlomifish.org.
