%D \module
%D   [      file=x-dir-05,
%D        version=2003.05.10, % around that time -)
%D          title=\CONTEXT\ Directory Handling,
%D       subtitle=Access,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\setvariables
  [filestate]
  [name=,base=,type=,size=,permissions=,date=]

\def\savefilestate
  {\dodoubleargument\dosavefilestate}

\def\dosavefilestate[#1][#2]%
  {\startnointerference
     \setxvariables
       [#1]
       [name=#2,base=,type=,size=,permissions=,date=]
     \executesystemcommand{texmfstart xmltools.rb --dir --pattern=\getvariable{#1}{name} --output=xmldir.tmp}
     \defineXMLprocess [files]
     \defineXMLprocess [directory]
     \defineXMLenvironment [file]
       {\defineXMLsave [base]
        \defineXMLsave [type]
        \defineXMLsave [size]
        \defineXMLsave [permissions]
        \defineXMLsave [date]}
       {\setxvariables
          [#1]
          [name=\XMLop{name},
           base=\XMLflush{base},
           type=\XMLflush{type},
           size=\XMLflush{size},
           permissions=\XMLflush{permissions},
           date=\XMLflush{date}]}
     \startXMLignore
     \processXMLfile{xmldir.tmp}
     \stopXMLignore
   \stopnointerference}

\def\getfilestate#1% old one
  {\savefilestate[filestate][#1]}

\endinput
