|I wrote a program with Visual basic 6.0 that copy a folder on a SD image file.(Simulated windows copy).|
At first, I read all sectors of SD volume and copy as a file on Hard Disk (make an image file) then read all files and folders that I wish to copy after that write cluster by cluster on image file.
Finally I restore image file in SD.
I haven't any problem with Windows XP and windows7(64bit), I can read, edit and delete files and folders from SD without any problem.(I can use windows explorer)
But all files(only files) are removed after I put SD on my mobile phone.!!!! I don't know why.
I do these steps for copy folder on an image file:
1- read folder data(short-name and long-name and created date-time and ...)
2- allocate a cluster as first cluster of folder from free FAT space.
3- make folder's data on parent's directory data cluster.(Set LNF and short-name , created date and time, modified date and time, First Cluster, Attributes, and ...)
4- copy All files(see below)
5- do all steps 1 to 4 for all subfolder of it.
1- read short-name and long-name and created date-time and ... of file.
2- allocate a cluster as first cluster of file from free FAT space.
3- read data of file and wite them on image file and allocate more cluster if need.
4- sign last cluster with EOF.
5- do all 1 to 4 fror all files of folder.
My SD is FAT32 formated with cluster size 4096 and sector size 512.
My program change these place on SD, FAT1 and FAT2 and main ROOT and free data clusters.