Search code examples
assemblyx86-16dostasmdosbox

Read a given file's attributes


I have a task in which they give me the path to a file and I have to print all the attributes of that file...

So far all what I have found on the internet is about writing/reading from a file, but this does not help a bit.

EDIT: It has to be done in assembly language EDIT2: I'm using windows 7 x64, but all my programs are compiled using TASM, TLINK and I'm using Turbo Debugger for debuggin


Solution

  • Since this seems to be homework/assignment related I'm going to direct you to the resources and Interrupt information that you'll need to perform the task, without writing actual code.

    • One of the best places for all thing MS-DOS/BIOS related is Ralph Brown's Interrupt List
    • When dealing with DOS and Files most of the routines of interest will likely be the DOS Int 21h functions
    • In particular you'll probably want to use DOS's Int 21h/AX=4300h Get File Attributes function.

      AX = 4300h
      DS:DX -> ASCIZ filename
      
      Return:
      CF clear if successful
      CX = file attributes (see #01420)
      AX = CX (DR DOS 5.0)
      CF set on error
      AX = error code (01h,02h,03h,05h) (see #01680 at AH=59h)
      

      You will also find the file attribute bits

      Bit(s)  Description     (Table 01420)
      7      shareable (Novell NetWare)
             pending deleted files (Novell DOS, OpenDOS)
      6      unused
      5      archive
      4      directory
      3      volume label.
             Execute-only (Novell NetWare)
      2      system
      1      hidden
      0      read-only