SD_FILE_SYSTEM - TIME UPDATE

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

SD_FILE_SYSTEM - TIME UPDATE

Post by ohararp » Mon Mar 24, 2008 1:45 am

Steven,

I am appending NMEA data in my gps logger and would like to update the time stamp on the files properties. How can I do that using the save file command? The close file command has this as an entry in the the routine but the sav file command does not.

When looking through the library I saw:

Code: Select all

Sub SetFileTimeModified(pSectorPos As Word, pDay, pMonth, pYear, pHours, pMinutes, pSeconds As Byte)
But seeing that this is not a public sub I didn't think it would work.
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Mon Mar 24, 2008 7:38 am

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

User avatar
ohararp
Posts: 194
Joined: Tue Oct 03, 2006 11:29 pm
Location: Dayton, OH USA
Contact:

Post by ohararp » Mon Mar 24, 2008 3:54 pm

Steven,

That works a real treat! I think you should add this to the official library eventually! Most of my code is nearly ported over to SF.
Thanks Ryan
$25 SMT Stencils!!!
www.ohararp.com/Stencils.html

User avatar
Steven
BETA Tester
Posts: 406
Joined: Tue Oct 03, 2006 8:32 pm
Location: Cumbria, UK

Post by Steven » Mon Mar 24, 2008 4:28 pm

Yes, I've made the change in my code and it will appear in the next update - thanks for letting me know it works. Good to hear that you have ported most of your code over now. I'm in the middle of writing my own application (a golf scorecard and GPS rangefinder that I've had lined up to do for a long time) and I've got to say that it's an absolute pleasure to write with the structured nature of Swordfish. It's got a 320x240 display with touchscreen and is looking rather good, even if I do say so myself.

Steve

Post Reply