summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-02-06 01:22:10 +0000
committerKarl Berry <karl@freefriends.org>2012-02-06 01:22:10 +0000
commit88ad42f78998b5210fa58a05e2e7750f897b2550 (patch)
tree6faffeb117d275760dd935be86714b25013bcec3 /Master/texmf-dist/source/latex/l3kernel/l3file.dtx
parent6406190e2336a4aa3036d7d8943c14c02a4ccadf (diff)
l3kernel 3287
git-svn-id: svn://tug.org/texlive/trunk@25306 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/l3kernel/l3file.dtx')
-rw-r--r--Master/texmf-dist/source/latex/l3kernel/l3file.dtx121
1 files changed, 110 insertions, 11 deletions
diff --git a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
index b60d534c225..12ce5b17b17 100644
--- a/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
+++ b/Master/texmf-dist/source/latex/l3kernel/l3file.dtx
@@ -35,7 +35,7 @@
%
%<*driver|package>
\RequirePackage{l3names}
-\GetIdInfo$Id: l3file.dtx 3158 2012-01-09 00:47:42Z bruno $
+\GetIdInfo$Id: l3file.dtx 3287 2012-01-31 22:08:14Z joseph $
{L3 Experimental file operations}
%</driver|package>
%<*driver>
@@ -88,7 +88,7 @@
% \cs{file_input:n}.
% \end{variable}
%
-% \begin{function}[TF]{\file_if_exist:n}
+% \begin{function}[TF, updated = 2012-01-25]{\file_if_exist:n}
% \begin{syntax}
% \cs{file_if_exist:nTF} \Arg{file name} \Arg{true code} \Arg{false code}
% \end{syntax}
@@ -102,7 +102,7 @@
% \end{texnote}
% \end{function}
%
-% \begin{function}{\file_add_path:nN}
+% \begin{function}[updated = 2012-01-25]{\file_add_path:nN}
% \begin{syntax}
% \cs{file_add_path:nN} \Arg{file name} \meta{tl var}
% \end{syntax}
@@ -113,11 +113,13 @@
% \begin{texnote}
% The \meta{file name} may contain both literal items and expandable
% content, which should on full expansion be the desired file name.
-% The expansion occurs when \TeX{} searches for the file.
+% Any active characters (as declared in \cs{l_char_active_seq}) will
+% \emph{not} be expanded, allowing the direct use of these in
+% file names.
% \end{texnote}
% \end{function}
%
-% \begin{function}{\file_input:n}
+% \begin{function}[updated = 2012-01-25]{\file_input:n}
% \begin{syntax}
% \cs{file_input:n} \Arg{file name}
% \end{syntax}
@@ -129,7 +131,34 @@
% \begin{texnote}
% The \meta{file name} may contain both literal items and expandable
% content, which should on full expansion be the desired file name.
-% The expansion occurs when \TeX{} searches for the file.
+% Any active characters (as declared in \cs{l_char_active_seq}) will
+% \emph{not} be expanded, allowing the direct use of these in
+% file names.
+% \end{texnote}
+% \end{function}
+%
+% \begin{function}[added = 2012-01-25]{\file_split_path_name_ext:nNNN}
+% \begin{syntax}
+% \cs{file_split_path_name_ext:nNNN} \Arg{name} \meta{path} \meta{filename} \meta{ext}
+% \end{syntax}
+% Splits the file \meta{name} into any \meta{path} (up to the last |/|),
+% any \meta{ext} (from the last |.| to the end of the \meta{name}),
+% and the the \meta{filename} (the rest of the \meta{name}). Thus for
+% example
+% \begin{verbatim}
+% \file_split_path_name_ext:nNNN { figures / example.foo.eps }
+% \end{verbatim}
+% will result in \meta{path} \texttt{figures/}, \meta{filename}
+% \texttt{example.foo} and \meta{ext} \texttt{eps}.
+% The three parts of the \meta{name} will be stored in the
+% token list variables given as the \meta{name}, \meta{path} and
+% \meta{filename} arguments.
+% \begin{texnote}
+% The \meta{name} may contain both literal items and expandable
+% content, which should on full expansion be the desired file name.
+% Any active characters (as declared in \cs{l_char_active_seq}) will
+% \emph{not} be expanded, allowing the direct use of these in
+% file names.
% \end{texnote}
% \end{function}
%
@@ -291,7 +320,7 @@
%
% \begin{macro}{\file_add_path:nN}
% \begin{variable}{\g_file_internal_ior}
-% \begin{macro}[aux]{\file_add_path_search:nN}
+% \begin{macro}[aux]{\file_add_path_aux:nN, \file_add_path_search:nN}
% The way to test if a file exists is to try to open it: if it does not
% exist then \TeX{} will report end-of-file. For files which are in the
% current directory, this is straight-forward. For other locations, a
@@ -300,14 +329,26 @@
% |#2| is returned empty.
% \begin{macrocode}
\ior_new:N \g_file_internal_ior
-\cs_new_protected:Npn \file_add_path:nN #1#2
+\cs_new_protected:Npn \file_add_path:nN #1
{
- \ior_open:Nn \g_file_internal_ior {#1}
+ \group_begin:
+ \tl_to_str_active_safe:Nx \l_file_internal_name_tl {#1}
+ \tl_if_in:NnT \l_file_internal_name_tl { ~ }
+ {
+ \msg_kernel_error:nnx { io } { space-in-file-name }
+ { \l_file_internal_name_tl }
+ }
+ \exp_args:NNo \group_end:
+ \file_add_path_aux:nN \l_file_internal_name_tl
+ }
+\cs_new_protected:Npn \file_add_path_aux:nN #1#2
+ {
+ \ior_open_unsafe:Nn \g_file_internal_ior {#1}
\ior_if_eof:NTF \g_file_internal_ior
{ \file_add_path_search:nN {#1} #2 }
{
\ior_close:N \g_file_internal_ior
- \tl_set:Nx #2 {#1}
+ \tl_set:Nn #2 {#1}
}
}
\cs_new_protected:Npn \file_add_path_search:nN #1#2
@@ -324,7 +365,7 @@
%</package>
\seq_map_inline:Nn \l_file_search_path_seq
{
- \ior_open:Nn \g_file_internal_ior { ##1 #1 }
+ \ior_open_unsafe:Nn \g_file_internal_ior { ##1 #1 }
\ior_if_eof:NF \g_file_internal_ior
{
\tl_set:Nx #2 { ##1 #1 }
@@ -382,6 +423,64 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\file_split_path_name_ext:nNNN}
+% \begin{macro}[aux]{\file_split_path_name_ext_aux:nNNN}
+% \begin{macro}[aux]{\file_split_path:wNNN, \file_split_name_ext:wNN}
+% Splits a file name into any path part, the file name and the extension,
+% which is considered as the part after the last |.|.
+% \begin{macrocode}
+\cs_new_protected:Npn \file_split_path_name_ext:nNNN #1
+ {
+ \group_begin:
+ \tl_to_str_active_safe:Nx \l_file_internal_name_tl {#1}
+ \tl_if_in:NnT \l_file_internal_name_tl { ~ }
+ {
+ \msg_kernel_error:nnx { io } { space-in-file-name }
+ { \l_file_internal_name_tl }
+ }
+ \exp_args:NNo \group_end:
+ \file_split_path_name_ext_aux:nNNN \l_file_internal_name_tl
+ }
+\cs_new_protected:Npn \file_split_path_name_ext_aux:nNNN #1#2#3#4
+ {
+ \tl_clear:N #2
+ \tl_clear:N #3
+ \file_split_path:wNNN #1 / \q_nil / \q_stop #2#3#4
+ }
+\cs_new_protected:Npn \file_split_path:wNNN #1 / #2 / #3 \q_stop #4
+ {
+ \quark_if_nil:nTF {#2}
+ { \file_split_name_ext:wNN #1 . \q_nil . \q_stop }
+ {
+ \tl_put_right:Nn #4 { #1 / }
+ \file_split_path:wNNN #2 / #3 \q_stop #4
+ }
+ }
+\cs_new_protected:Npn \file_split_name_ext:wNN #1 . #2 . #3 \q_stop #4#5
+ {
+ \quark_if_nil:nTF {#2}
+ {
+ \tl_if_empty:NTF #4
+ {
+ \tl_set:Nn #4 {#1}
+ \tl_clear:N #5
+ }
+ { \tl_set:Nn #5 {#1} }
+ }
+ {
+ \tl_put_right:Nx #4
+ {
+ \tl_if_empty:NF #4 { . }
+ #1
+ }
+ \file_split_name_ext:wNN #2 . #3 \q_stop #4#5
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}{\file_path_include:n}
% \begin{macro}{\file_path_remove:n}
% Wrapper functions to manage the search path.