View previous topic :: View next topic |
Author |
Message |
soldeersmurf
Joined: 07 Apr 2014 Posts: 5
|
Posted: Sat Oct 24, 2015 1:47 am Post subject: Find a directory and write a file |
|
|
Hi Niclas,
Thanks again for your nice work!
My (daily) logging application worked fine for about 3/4 year. I guess the root directory was full (but could not verify that), so I decided to create subdirs for each month to write a daily file.
Q: FAT32 directories supposedly have no limit; does Kokkekat automatically make the extension?
So, I first try to find a directory (for the present month), and try to write a file to it if it exists.
I can indeed find the dir (gosub sdfindentryindirectory gives sdstatus=48 and sdclusterd=NN). The value NN seems OK after inspection with a diskeditor. It is indeed the place where the directory resides.
Now creating a file there :
gosub sdreadfsinfo
sdcreatemode = 0
sdstartclusterd= NN
gosub sdcreatefileordir
screws up the card (there is no new dir-entry made in cluster NN, and the card is made inaccessible)
Also, trying to find a directory followed by creating a new directory in the root fails.......
However, if the first program action is to create a directory (in the root, sdstartclusterd= 0), catch the right (dir) cluster, and try to create a file-entry in the new directory it does work.
Appending to an existing file also works (I know the filename, so no need to use sdfindentryindirectory)
So it seems that finding a file with sdfindentryindirectory is causing some change which I cannot find. It looks that when I start 'fresh', creation goes well.
Q: I guess I could execute an sdinitfs after a search? Should I or is there another cure?
BTW. I disabled sdusedirlist but use sdusefind.
Another question: Do I have to use fsinfo? Omitting it would free up some valuable bytes of codespace....
I dearly missed the Find_dir_and_write_file example.
Best regards,
Michael |
|
Back to top |
|
|
soldeersmurf
Joined: 07 Apr 2014 Posts: 5
|
Posted: Mon Oct 26, 2015 3:08 am Post subject: |
|
|
Hi Niclas,
I tried executing sdfsinit after the search, to no avail.
So I made a workaround by storing the clusternumber in EEprom after a search (and two flags: searched and match) and restart the program (JMP 0).
After the restart my code first reads the flags, to see if a search was executed last time and if there was a match found. It will reset the 'searched'-flag. If the match-flag was set, the clusternumber is read and used to write files....... The 'search-made' flag.
Maybe a bit complicated, but it works.
Regards,
Michael |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|