On 05/31/2017 10:00 PM, Hans Hagen wrote: > On 5/31/2017 8:51 PM, Pablo Rodriguez wrote: >> Dear list, >> >> I need to add checksums to files I attach to PDF documents. >> [...] >> Directories are a problem here. I mean, \shatwo{Desktop/i-context.pdf} >> cannot work in Windows. >> >> Which would be the way to make it work in Windows?
Many thanks for your code, Hans. Pablo > \starttext > \startluacode > local function sha(cmd,name) > local f = io.popen(string.format("%s -b %q",cmd,name),"rb") > if f then > local s = f:read("*a") > f:close() > -- s = string.longtostring(s) > return string.match(s,"%s*([A-Fa-f0-9]+)") > end > end > > function document.sha256(name) > local ok = sha("sha256sum",name) > if ok then > context(ok) > end > end > > function document.sha512(name) > local ok = sha("sha512sum",name) > if ok then > context(ok) > end > end > \stopluacode > > \def\shatwo #1{\ctxlua{document.sha256("#1")}} > \def\shafive#1{\ctxlua{document.sha512("#1")}} > > \shafive{fd.pdf} > \shafive{foo/fd.pdf} > > \stoptext -- http://www.ousia.tk ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________