SD Card File Copy - How to copy a file to another - CODE POSTED
Paul_H
Posts: 85
Check below for my SDFileCopy.ZIP code. You need to rename back to .zip.
Paul
Hi All,
Here's a question regarding SD Card file copies. I'm using Tom Rokicki's SD programs (thank you Tom) and want to copy one existing file into another. However I can only open one file at a time ( or that is what I have been successful with!)
So procedurally, I could open the SRC file, copy a number of Longs to memory, close the original, then open my DEST file and copy in from memory, close it, and repeat. However this means I need to keep track of where I was in the SRC file for consecutive reads.
Is there any more direct method to solve this problem - like opening 2 files at once and copying directly, or have I described the most direct path of sequentially opening the files?
Thanks for the advice!
Paul
Post Edited (Paul_H) : 5/24/2008 3:27:53 AM GMT
Paul
Hi All,
Here's a question regarding SD Card file copies. I'm using Tom Rokicki's SD programs (thank you Tom) and want to copy one existing file into another. However I can only open one file at a time ( or that is what I have been successful with!)
So procedurally, I could open the SRC file, copy a number of Longs to memory, close the original, then open my DEST file and copy in from memory, close it, and repeat. However this means I need to keep track of where I was in the SRC file for consecutive reads.
Is there any more direct method to solve this problem - like opening 2 files at once and copying directly, or have I described the most direct path of sequentially opening the files?
Thanks for the advice!
Paul
Post Edited (Paul_H) : 5/24/2008 3:27:53 AM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1011, so be surprised!
Advertisement sponsored by dfletch:
Come and join us on the Propeller IRC channel for fast and easy help!
Channel: #propeller
Server: irc.freenode.net or freenode.net
If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Michael Park
PS, BTW, and FYI:
To search the forum, use search.parallax.com (do not use the Search button).
Check out the Propeller Wiki: propeller.wikispaces.com/
I think someone started this. I do not know how far along they got. I'll have to do some
looking and see if I can find who was going to do this.
There are all sorts of hacky solutions possible, but I'd avoid them.
Maybe I'll spend a bit of time and support multiple files. That shouldn't be too hard. (There
are some tricky parts, though, like making sure the same file is not opened twice, or if we
need to support that, then making sure the data between the two stays in sync. Easiest for
now is just making sure if more than one file is open that it is not one of the other files
already open.)
Of course as soon as I release it someone will use it to open two separate files from
two separate cogs, and trash their filesystem. So I'll need to either protect the routines
using an appropriate mutex, or else add some other code to check this doesn't happen.
I am reading that the best answer for me may to open, read1, remember loc1, close1, open2 write2 close2, lather rinse, and repeat ...
I will investigate - thanks.
@tpw_man - if your idea does work, please post. And Happy BDay - I remember when your sig was only 1010...
Thanks,
Paul
I was able to create an ugly but working SD card copy routine. Rename attached to zip for the SPIN files, or copy the following text.
As it is now, there is a LOT of opening and closing of files as it loops through the SRC data file and keeping its place. I have not yet messed with the FLOC pointer but that may speed things up.
Until I figure it out, Please enjoy, and post your thoughts.
Thanks!
Paul
It is SLOW because I'm using the spin SD driver rather than the faster assembler ones, and also because I iterate through the source file everytime it is opened.
So any speed ideas are appreciate!
Paul
Glad to help - yeah I probably am not going to up the copy speed either until I have a ton of free time (aka probably never), and I only use the code once to create a KML file a before I start loggin GPS. My COPY takes about 30 sec, and I can live with it for now.
Good luck and please post your SD code whenever you get there!
Paul