⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getftime.gml

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 GML
字号:
.func _dos_getftime
#include <&doshdr>
unsigned _dos_getftime( int &fd,
                        unsigned short *date,
                        unsigned short *time );
.ixfunc2 '&DosFunc' &func
.funcend
.desc begin
The &func function uses system call 0x57 to get the date and time
that the file associated with
.arg &fd
was last modified.
The date consists of the year, month and day packed into 16 bits as follows:
.begnote $compact $setptnt 10
.termhd1 Bits
.termhd2 Meaning
.note bits 0-4
Day (1-31)
.note bits 5-8
Month (1-12)
.note bits 9-15
Year (0-119 representing 1980-2099)
.endnote
.np
The time consists of the hour, minute and seconds/2 packed into 16 bits
as follows:
.begnote $compact $setptnt 10
.termhd1 Bits
.termhd2 Meaning
.note bits 0-4
Seconds/2 (0-29)
.note bits 5-10
Minutes (0-59)
.note bits 11-15
Hours (0-23)
.endnote
.desc end
.return begin
The &func function returns zero if successful.
Otherwise, it returns an OS error code and sets
.kw errno
accordingly.
.return end
.see begin
.seelist _dos_getftime _dos_setftime
.see end
.exmp begin
#include <stdio.h>
#include <&doshdr>
#include <fcntl.h>
.exmp break
#define YEAR(t)   (((t & 0xFE00) >> 9) + 1980)
#define MONTH(t)  ((t & 0x01E0) >> 5)
#define DAY(t)    (t & 0x001F)
#define HOUR(t)   ((t & 0xF800) >> 11)
#define MINUTE(t) ((t & 0x07E0) >> 5)
#define SECOND(t) ((t & 0x001F) << 1)
.exmp break
void main()
  {
    int      &fd;
    unsigned short date, time;
.exmp break
    if( _dos_open( "file", O_RDONLY, &amp.&fd ) != 0 ) {
      printf( "Unable to open file\n" );
    } else {
      printf( "Open succeeded\n" );
      _dos_getftime( &fd, &amp.date, &amp.time );
      printf( "The file was last modified on %d/%d/%d",
              MONTH(date), DAY(date), YEAR(date) );
      printf( " at %.2d:%.2d:%.2d\n",
              HOUR(time), MINUTE(time), SECOND(time) );
      _dos_close( &fd );
    }
  }
.exmp output
Open succeeded
The file was last modified on 12/29/1989 at 14:32:46
.exmp end
.class DOS
.system

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -