{***********************************************************************}
{									}
{ __SetAtFil  Set the attribute of a file				}
{									}
{ procedure __SetAtFil(PathName : _Path;				}
{		       FileAttr : byte; 				}
{		  var ErrorCode : word);				}
{									}
{	      PathName	File path name of the file whose attribute	}
{			is to be altered.				}
{	      FileAttr	Attribute to be assigned to the file.		}
{	      ErrorCode The returned error status code: 		}
{			(0) File attribute successfully altered.	}
{			(2) File not found.				}
{			(3) Path not found.  One of the entries in the	}
{			    path was not present.			}
{			(5) Access denied; cannot alter the attribute	}
{			    of subdirectories or volume labels. 	}
{			If DOS version 3.0 or later is used, a call to	}
{			__RetErUtl can be made to return more informa-	}
{			tion on the error.				}
{									}
{ Description __SetAtFil alters the attribute of the specified file.	}
{	      The list of available attributes are defined in the	}
{	      unit interface and are:					}
{									}
{	      _GENERAL	  = 0;	    General, no attribute		}
{	      _READ	  = 1;	    Read only  file			}
{	      _HIDDEN	  = 2;	    Hidden file 			}
{	      _SYSTEM	  = 4;	    System file 			}
{	      _VOLUME	  = 8;	    Volume label			}
{	      _DIR	  = 16;     Subdirectory			}
{	      _ARCHIVE	  = 32;     File altered since last backup	}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc.  1987		}
{_______________________________________________________________________}

procedure __SetAtFil(PathName : _Path;
		     FileAttr : byte;
		var ErrorCode : word);

  var
    PathZ   : _Path;		       { ASCIIZ string for PathName	}
    PathLen : integer;
    Reg     : registers;

  begin {__SetAtFil}

    { First construct the ASCIIZ string representing the path name.	}
    { Notice that PathName is moved to PathZ[0], and the trailing NUL	}
    { character is put at PathZ[Length(PathName)].			}

    PathLen := Length(PathName);
    Move(PathName[1],PathZ,PathLen);
    PathZ[PathLen] := #0;

    with Reg do
      begin
	AH := $43;		       { Set file attribute		}
	AL := $01;
	DS := Seg(PathZ);
	DX := Ofs(PathZ);
	CX := FileAttr;
	Intr(_DOS,Reg);
	if ((Flags and FCarry) <> 0) then
	   ErrorCode := AX
	else
	   ErrorCode := 0
     end

  end;	{__SetAtFil}
