summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/x-dir-05.mkiv
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2010-05-24 14:05:02 +0000
committerTaco Hoekwater <taco@elvenkind.com>2010-05-24 14:05:02 +0000
commit57ea7dad48fbf2541c04e434c31bde655ada3ac4 (patch)
tree1f8b43bc7cb92939271e1f5bec610710be69097f /Master/texmf-dist/tex/context/base/x-dir-05.mkiv
parent6ee41e1f1822657f7f23231ec56c0272de3855e3 (diff)
here is context 2010.05.24 13:05
git-svn-id: svn://tug.org/texlive/trunk@18445 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/x-dir-05.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/x-dir-05.mkiv72
1 files changed, 72 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/x-dir-05.mkiv b/Master/texmf-dist/tex/context/base/x-dir-05.mkiv
new file mode 100644
index 00000000000..c29c9ea2aba
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/x-dir-05.mkiv
@@ -0,0 +1,72 @@
+%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 / Hans Hagen \& Ton Otten}]
+%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=]
+
+% \savefilestate[zip-latest][context/latest/cont-#2.zip]%
+
+\startluacode
+ local filestates = { }
+ function commands.savefilestate(tag,name)
+ if not filestates[tag] then
+ local attr = lfs.attributes(name)
+ if attr then attr.name = name end
+ filestates[tag] = attr
+ end
+ end
+ function commands.getfilestatevariable(tag,name)
+ local fs = filestates[tag]
+ if fs then
+ local value
+ if name == "base" then
+ value = file.basename(fs.name)
+ elseif name == "type" then
+ value = file.extname(fs.name)
+ elseif name == "date" then
+ value = os.date("%Y-%m-%d %H:%M",fs.modification)
+ else
+ value = fs[name] or ""
+ end
+ tex.sprint(tex.vrbcatcodes,value)
+ end
+ end
+\stopluacode
+
+\def\getfilestatevariable#1#2%
+ {\ctxlua{commands.getfilestatevariable("#1","#2")}}
+
+\def\savefilestate
+ {\dodoubleargument\dosavefilestate}
+
+\def\dosavefilestate[#1][#2]%
+ {\ctxlua{commands.savefilestate("#1","#2")}%
+ \setxvariables
+ [#1]
+ [name={#2},
+ base=\getfilestatevariable{#1}{base},
+ type=\getfilestatevariable{#1}{type},
+ size=\getfilestatevariable{#1}{size},
+ date=\getfilestatevariable{#1}{date},
+ permissions=\getfilestatevariable{#1}{permissions}]}
+
+\def\getfilestate#1% old one
+ {\savefilestate[filestate][#1]}
+
+\endinput