This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Http server with file time stamp

Hi,

I am using fatfs file system.

elm-chan.org/.../stat.html

I need to return fdate and ftime convert into 32 bit number

void netHTTPs_fstat (const char *fname, uint32_t *fsize, uint32_t *ftime)
{ *ftime = ??
}

Thanks,
Naeem

Parents
  • Got the answer.

    Here is working code
    __current_date and __current_time is my own structure.
    I set windows date and time on these structure. need some adjustment for C tm structure.

    
    void netHTTPs_fstat (const char *fname, uint32_t *fsize, uint32_t *ftime)
    {
            FILINFO fno;
            FRESULT fr = f_stat(fname, &fno);
            if (fr == FR_OK)
            {
                    *fsize = fno.fsize;
                    tm time_stamp;
                    time_stamp.tm_year = __current_date.year_ - 1900; // years since 1900
    // months since January (0-11)
                    time_stamp.tm_mon = __current_date.month_ - 1;
                    time_stamp.tm_mday = __current_date.day_;
                    time_stamp.tm_hour = __current_time.hour_;
                    time_stamp.tm_min = __current_time.min_;
                    time_stamp.tm_sec = __current_time.sec_;
                    time_stamp.tm_isdst = false;
                    *ftime = mktime(&time_stamp);
            }
            else
            {
                    *ftime = 0;
                    *fsize = 0;
            }
    
            #ifdef PRINTF_DEBUG
            printf("netHTTPs_fstat file_name='%s' size=%u\n", fname, *fsize);
            #endif
    }
    
    

    Thanks,
    Naeem

Reply
  • Got the answer.

    Here is working code
    __current_date and __current_time is my own structure.
    I set windows date and time on these structure. need some adjustment for C tm structure.

    
    void netHTTPs_fstat (const char *fname, uint32_t *fsize, uint32_t *ftime)
    {
            FILINFO fno;
            FRESULT fr = f_stat(fname, &fno);
            if (fr == FR_OK)
            {
                    *fsize = fno.fsize;
                    tm time_stamp;
                    time_stamp.tm_year = __current_date.year_ - 1900; // years since 1900
    // months since January (0-11)
                    time_stamp.tm_mon = __current_date.month_ - 1;
                    time_stamp.tm_mday = __current_date.day_;
                    time_stamp.tm_hour = __current_time.hour_;
                    time_stamp.tm_min = __current_time.min_;
                    time_stamp.tm_sec = __current_time.sec_;
                    time_stamp.tm_isdst = false;
                    *ftime = mktime(&time_stamp);
            }
            else
            {
                    *ftime = 0;
                    *fsize = 0;
            }
    
            #ifdef PRINTF_DEBUG
            printf("netHTTPs_fstat file_name='%s' size=%u\n", fname, *fsize);
            #endif
    }
    
    

    Thanks,
    Naeem

Children