#include <iostream.h>
#include <iomanip.h>
#include <dos.h>
#include <conio.h>

union
{
 unsigned char b;
 struct
 {
  unsigned b7:1;
  unsigned b6:1;
  unsigned b5:1;
  unsigned b4:1;
  unsigned b3:1;
  unsigned b2:1;
  unsigned b1:1;
  unsigned b0:1;
 }bit;
} byte;

void main ()
{
 clrscr();

 REGS inregs,outregs;
 SREGS sregs;

 char filename[100];
 cout << "Vvedite imya faila: ";
 cin >> filename;

 inregs.h.al = 0x36;
 inregs.h.ah = 0x36;
 inregs.x.dx = FP_OFF(filename);
 sregs.ds    = FP_SEG(filename);
 intdosx(&inregs,&outregs,&sregs);

 int err = outregs.h.al;
 int att = outregs.h.cl;
 cout << "err = " << err;
 switch(err)
 {
  case 0x01: cout << "\nNe korrektnoe znachenie al";break;
  case 0x02: cout << "\nFail ne naiden"; break;
  case 0x03: cout << "\nFail ne dostupen";break;
  case 0x05: cout << "\nDirektoria ili metka toma";break;


  default:
   cout << "\nAtributi faila("<<att<<"):";
   //int c;
   //c=att;if(c & 128) cout << "\nTolko chtenie";
   //c=att;if(c & 64)  cout << "\nSkritiy fail";
   //c=att;if(c & 32)  cout << "\nSistemniy fail";
   //c=att;if(c & 16)  cout << "\nMetka toma";
   //c=att;if(c & 8)   cout << "\nPoddirectoriya";
   //c=att;if(c & 4)   cout << "\nArhivniy fail";
   byte.b = (unsigned char)att;
   cout << byte.bit.b0<< byte.bit.b1<< byte.bit.b2<< byte.bit.b3
	<< byte.bit.b4<< byte.bit.b5<< byte.bit.b6<< byte.bit.b7;
   if(byte.bit.b7) cout << "\nTolko chtenie";
   if(byte.bit.b6) cout << "\nSkritiy fail";
   if(byte.bit.b5) cout << "\nSistemniy fail";
   if(byte.bit.b4) cout << "\nMetka toma";
   if(byte.bit.b3) cout << "\nPoddirectoriya";
   if(byte.bit.b2) cout << "\nArhivniy fail";
 }

 getch();
}