# How to use 'lfs' library in LuaLaTeX preamble?

I need to define absolute path of .tex file, and I already learned how to do it:

\edef\currfileabsdir{\directlua{tex.sprint(lfs.currentdir())}/}


What I don't know is how to include lfs library to my LuaLaTeX preamble. I used LaTeX for the few years, but I don't have not TeX nor Lua programming experience.

In this answer, I saw the code like this:

\usepackage{luacode}

\begin{luacode}
require "lfs"
\end{luacode}


I did not tried this code yet, but even it enough to run \edef\currfileabsdir{\directlua{tex.sprint(lfs.currentdir())}/} I need some comments about solution.

MWE:

\documentclass[a4paper, twoside]{ltjsarticle}

\usepackage{luatexja-fontspec}

\edef\currfileabsdir{\directlua{tex.sprint(lfs.currentdir())}/}

\setmainjfont[
Path          = \currfileabsdir,
UprightFont   = fonts/HGS_Mincho/HGRMB.ttc,
BoldFont      = fonts/HGS_Mincho/HGRME.ttc
]{nishiki-teki}

\begin{document}
done
\end{document}


The lfs library is available out-of-the-box in LuaTeX. As such, you do not need to do anything special: it will 'just work'. A very minimal demo for both plain LuaTeX and LuaLaTeX:
\directlua{print(lfs.currentdir())}