0x57 Nastav dátum a čas posledného zápisu do súboru (AL=1)
|
|
|
|
AH = 0x57
AL = 1
BX = rukovä súboru
CX = nový čas
DX = nový dátum
Vracia :
ak je nastavená vlajka CF
AX = kód chyby (0x01, 0x06)
Bitové pole času :
Bit(y)
|
Popis
|
15-11
|
hodiny (0-23)
|
10-5
|
minúty
|
4-0
|
sekundy/2
|
Bitové pole dátumu :
Bit(y)
|
Popis
|
15-9
|
rok -1980
|
8-5
|
mesiac
|
4-0
|
deň
|
Príklad :
#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include <conio.h>
struct DATUM { // 16 bitové pole
unsigned den : 5; // dni
unsigned mes : 4; // mesiace
unsigned rok : 7; // rok - 1980
};
struct CAS { // 16 bitové pole
unsigned sek : 5; // dve sekundy
unsigned min : 6; // minúty
unsigned hod : 5; // hodiny
};
void main(void)
{
struct DATUM *datum = new struct DATUM;
struct CAS *cas = new struct CAS;
union REGS regs;
struct SREGS segregs;
unsigned int subor=0;
regs.h.ah = 0x3D;
regs.h.al = 0; // 0 - na čítanie
// 1 - na zápis
// 2 - čítanie a zápis
char str[]="pokus.txt";
regs.x.dx = FP_OFF(str);
segregs.ds = FP_SEG(str);
clrscr();
intdosx(®s, ®s, &segregs);
if (regs.x.cflag==0)
{
subor = regs.x.ax;
printf("\nSúbor \"%s\" bol otvorený a má rukovä c. %d", str, regs.x.ax);
}
else
printf("\nSúbor nebol otvorený, vznikla chyba č. : %d - %s", regs.x.ax, sys_errlist[regs.x.ax]);
getch();
if (subor != 0)
{
regs.h.ah = 0x57; // zisti/zmeň čas/dátum súboru
regs.h.al = 1; // 0 - zisti čas/dátum
// 1 - nastav čas/dátum
regs.x.bx = subor; // rukovä otvoreného súboru
datum->den = 1;
datum->mes = 1;
datum->rok = 1999 - 1980;
cas->hod = 1;
cas->min = 0;
cas->sek = 14;
regs.x.cx = (unsigned int)cas; // nastavovaný čas
regs.x.dx = (unsigned int)datum; // nastavovaný dátum
intdos(®s, ®s);
if (regs.x.cflag==0)
printf("\nDátum a čas súboru \"%s\" bol nastavený", str);
else
printf("\nDátum a čas súboru %s sa nenastavil, vznikla chyba č. : %d - %s", str,regs.x.ax, sys_errlist[regs.x.ax]);
getch();
regs.x.bx = subor; // rukovä otvoreného súboru
regs.h.ah = 0x3E; // zatvorenie súboru
intdos(®s, ®s);
if (regs.x.cflag==0)
printf("\nSúbor \"%s\" bol zatvorený", str);
else
printf("\nSúbor nebol zatvorený, vznikla chyba č. : %d - %s", regs.x.ax, sys_errlist[regs.x.ax]);
getch();
}
delete cas;
delete datum;
}