Ryan,
Try changing your SaveFile sub to:
Code: Select all
{
********************************************************************************
* Name : SaveFile(PUBLIC) *
* Purpose : Write all of buffer to file and update file size & FAT clusters. *
* : If disk removed, file should be safe. Has same effect as closing *
* : file and re-opening with AppendFile, except works quicker. *
* : Return: True = Success, False = Read/write error *
********************************************************************************
}
#if SD_SUPPORT_MULTIPLE_FILES = TRUE
Public Function SaveFile(pFileNumber As ShortInt, pDay As Byte = 1, pMonth As Byte = 1, pYear As Byte = 1, pHours As Byte = 0, pMinutes As Byte = 0, pSeconds As Byte = 0) As Boolean
Dim TempCurrentSectorPos As Word
Dim TempCurrentSector As LongWord
Dim TempFileSize As LongWord
FileNumber(pFileNumber)
#else
Public Function SaveFile(pDay As Byte = 1, pMonth As Byte = 1, pYear As Byte = 1, pHours As Byte = 0, pMinutes As Byte = 0, pSeconds As Byte = 0) As Boolean
Dim TempCurrentSectorPos As Word
Dim TempCurrentSector As LongWord
Dim TempFileSize As LongWord
#endif
If File.IsOpen Then
If Disk.RWError Then
SaveFile = False
Exit
EndIf
TempCurrentSectorPos = File.CurrentSectorPos // Store pointers to temp pointers
TempCurrentSector = File.CurrentSector
TempFileSize = File.Size
#if SD_SUPPORT_MULTIPLE_FILES = TRUE
CloseFile(pFileNumber, pDay, pMonth, pYear, pHours, pMinutes, pSeconds) // Save file size etc..
#else
CloseFile(pDay, pMonth, pYear, pHours, pMinutes, pSeconds)
#endif
File.IsOpen = True
File.CurrentSector = TempCurrentSector // Recover pointers from temp pointers
ReadSector(File.CurrentSector) // Recover buffer contents
File.CurrentSectorPos = TempCurrentSectorPos
File.Size = TempFileSize
EndIf
SaveFile = True
End Function
You can now pass it optional parameters for the date & time, as you can for CloseFile.
I've not tested this, but it should work - let me know.
Steve