DependableSystemsLab / ThingsJS

ThingsJS is a framework for running JavaScript applications on IoT devices such as Raspberry PIs. For more details, see below:
http://thingsjs.io
MIT License
16 stars 5 forks source link

Global File system: path direct error in readfile and writefile function #40

Closed aliciatang07 closed 6 years ago

aliciatang07 commented 6 years ago

The writefile and readfile function only support for the operation in the root folder, once I want to specify a subdirectory like apps, it feels to navigate inside to do the read or write operation. For example GFS.readFile('./code/test.json', function(err,data){ console.log(data); }) should read te file inside the code folder, but it throw me an error as not found. for write GFS.writeFile('./code/test.json', testdata,function(err,data){ console.log(data); }), it failed to write data inside code folder and only write it to root folder.

xyzwwwww commented 6 years ago

I am merging this issue with the previous one which was open.

jungkumseok commented 6 years ago

Currently you cannot use unix-style relative paths because what the cwd (current working directory) is for a ThingsJS worker is unclear. Once we establish what the cwd would be, we can start supporting relative paths. For now, let's just stick to absolute paths.

xyzwwwww commented 6 years ago

It is able to read from the folders. We tested. The problem currently is it can only write to nested folders if there already exists a file. If the file does not exist, it is unable to create the file in the nested folder. So a separate create function should do the task?

Also second thing is will the users be running the benchmarks? The reason I ask is for testing and running the benchmarks right now we have a small hack that works but it might not work for the users.

On Mon, 8 Oct, 2018, 11:10 AM Xuejie(Alicia) Tang, notifications@github.com wrote:

The writefile and readfile function only support for the operation in the root folder, once I want to specify a subdirectory like apps, it feels to navigate inside to do the read or write operation. For example GFS.readFile('./code/test.json', function(err,data){ console.log(data); }) should read te file inside the code folder, but it throw me an error as not found. for write GFS.writeFile('./code/test.json', testdata,function(err,data){ console.log(data); }), it failed to write data inside code folder and only write it to root folder.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DependableSystemsLab/ThingsJS/issues/40, or mute the thread https://github.com/notifications/unsubscribe-auth/AJtt-GpCJ9Wmy8d-tXkKIg89FeogBAZGks5ui5T1gaJpZM4XNbK_ .