Acode icon indicating copy to clipboard operation
Acode copied to clipboard

Plugin Development - need to incrementally write file

Open redabourebaba opened this issue 1 year ago • 4 comments

Hello,

Thank you for your great job. I enjoy your application. I decided to extend the application by developing some plugins. I will start by developing a visual git management plugin. In my code, I have to create file, and write data into it. The creation works fine with fs.createFile(fileName, contents). I also can write into the file with fs.writeFile(contents). The problem is that writeFile replaces existing content with the new content. Is there an option to add the new content without removing existing data ?

Thank you for your help.

redabourebaba avatar Apr 05 '24 14:04 redabourebaba

Possible solution is to use "append" to write data to file in SDcard.java Cordova plugin.

Screenshot_2024-04-05-17-14-15-017_com foxdebug acodefree

redabourebaba avatar Apr 05 '24 15:04 redabourebaba

I see, I'll add new fs method append in next update. Thanks for suggestion.

deadlyjack avatar Apr 06 '24 08:04 deadlyjack

If it is possible to implement a nodejs fs library like code, this will be more simple to integrate external libraries, like isomorphic-git per example. What do you think about it ? Otherwise, I can continue using a wrapper to map functions.

redabourebaba avatar Apr 07 '24 04:04 redabourebaba

In my code, I have to create file, and write data into it. The creation works fine with fs.createFile(fileName, contents). I also can write into the file with fs.writeFile(contents). The problem is that writeFile replaces existing content with the new content. Is there an option to add the new content without removing existing data ?

Thank you for your help.

You can easily implement it at your own. By reading the existing content then writing whole new content by combining old and new data

Check here

bajrangCoder avatar Sep 02 '24 13:09 bajrangCoder

Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Acode, please let us know by commenting on this issue(i.e Bump!), and we will keep it open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, we'll close it in 14 days. Thanks for your help!

github-actions[bot] avatar Jun 03 '25 03:06 github-actions[bot]

Hi,

You can close this issue. I managed to write function to do this.

Now, I have another issue related to read/write performance with cordova plugin. While nodejs takes 2 ms to read a file, the same operation performed with SDCard.java class takes 20 ms.

I will stop developping my extension if I can't make it faster, because for projects with hundreds of files the reponse time is very bad.

Thank you for support.

redabourebaba avatar Jun 05 '25 17:06 redabourebaba