Fat32: time of the created file

General discussion on mikroPascal PRO for AVR.
Post Reply
Author
Message
martgg
Posts: 18
Joined: 07 Jul 2017 15:40

Fat32: time of the created file

#1 Post by martgg » 07 Jul 2017 16:33

Hi.
How to get the time of the created file?

FAT32_GetAttr - This routine extracts file attributes information. (only: attr : ^uint8).
FAT32_GetCTime - This routine gets created time of a file.
FAT32_GetMTime - This routine gets modified time of a file.

with Library:
var TimeCre : __TIME;

FAT32_GetCTime('FILE_A.TXT', @TimeCre); //

Error: Incompatable types (comlex type to simple type)

User avatar
dusan.poluga
mikroElektronika team
Posts: 780
Joined: 02 Feb 2017 14:21

Re: Fat32: time of the created file

#2 Post by dusan.poluga » 11 Jul 2017 09:24

Hi,

Please try to declare the filename in a array like this.

Code: Select all

var FileName: string[20];
var TimeCre : __TIME;
Then in your main assign it like this.

Code: Select all

FileName  := 'FILE1.TXT';
And assign the time values like shown.

Code: Select all

        TimeCre.Year   := 2011;       // initialize time ...
        TimeCre.Month  := 8;
        TimeCre.Day    := 11;
        TimeCre.Hour   := 16;
        TimeCre.Minute := 20;
        TimeCre.Second := 11;
The time in this structure will not update automatically the user will have to update it.
Time can be incremented like this.

Code: Select all

FAT32_IncTime(2*60*60 + 30*60 + 40);   // increment time stamp by 2 hours, 30 minutes and 40 seconds
To get the creation time you would run the command like shown below.

Code: Select all

FAT32_getCTime(@FileName, @tm); 

Best Regards,
Dusan Poluga.

martgg
Posts: 18
Joined: 07 Jul 2017 15:40

Re: Fat32: time of the created file

#3 Post by martgg » 13 Apr 2018 18:00

Hi.
There are many files on the SD.
One of them is FILE1.TXT

--A----- 6194 13/04/2018 19:17 FILE1.TXT

How to read the date: 13/04/2018 and time: 19:17 ?

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: Fat32: time of the created file

#4 Post by petar.suknjaja » 16 Apr 2018 18:13

Hi,

Can you post some more details about your problem?

Kind regards,
Petar

martgg
Posts: 18
Joined: 07 Jul 2017 15:40

Re: Fat32: time of the created file

#5 Post by martgg » 17 Apr 2018 08:43

Hi.

// --A----- 6194 11/04/2018 15:50 FILE1.TXT
// tm, TimeCre : __TIME; //

File_ := FILE1.TXT;
if (0 = FAT32_GetCTime(@File_, @TimeCre)) then //if operation was successful
begin // ...
end;
ByteToStr(TimeCre.Day, txt); //
UART2_Write_Text(txt); UART2_Write_Text(' '); //
ByteToStr(TimeCre.Month, txt); //
UART2_Write_Text(txt); UART2_Write_Text(' '); //
ByteToStr(TimeCre.Year -2000, txt); //
UART2_Write_Text(txt); UART2_Write_Text(' '); //
ByteToStr(TimeCre.Hour, txt); //
UART2_Write_Text(txt); UART2_Write_Text(' ');//
ByteToStr(TimeCre.Minute, txt); //
UART2_Write_Text(txt); //
UART2_Write(13);UART2_Write(10);

On the screen: 16 4 18 19 13
What type: Day, Month, Year, Hour, Minute? Byte or word or ... ?

Yes!!!
FAT32_Dir(): --A----- 6194 11/04/2018 15:50 FILE1.TXT - date of change
FAT32_GetCTime: On the screen: 16 4 18 19 13 - date of creation

All OK.

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: Fat32: time of the created file

#6 Post by petar.suknjaja » 23 Apr 2018 16:06

Hi,
Nice to hear that you managed to find the solution for yourself.

Kind regards,
Petar

Post Reply

Return to “mikroPascal PRO for AVR General”