summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/l3kernel/l3file.sty
blob: 5ee45083280d627a0f254c49e67af3b903a75d1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
%%
%% This is file `l3file.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% l3file.dtx  (with options: `package')
%% 
%% EXPERIMENTAL CODE
%% 
%% Do not distribute this file without also distributing the
%% source files specified above.
%% 
%% Do not distribute a modified version of this file.
%% 
%% File: l3file.dtx Copyright (C) 2009-2011 The LaTeX3 Project
%%
%% It may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License (LPPL), either version 1.3c of this
%% license or (at your option) any later version.  The latest version
%% of this license is in the file
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% This file is part of the "l3kernel bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%%
%% The released version of this bundle is available from CTAN.
%%
%% -----------------------------------------------------------------------
%%
%% The development version of the bundle can be found at
%%
%%    http://www.latex-project.org/svnroot/experimental/trunk/
%%
%% for those people who are interested.
%%
%%%%%%%%%%%
%% NOTE: %%
%%%%%%%%%%%
%%
%%   Snapshots taken from the repository represent work in progress and may
%%   not work or may contain conflicting material!  We therefore ask
%%   people _not_ to put them into distributions, archives, etc. without
%%   prior consultation with the LaTeX3 Project.
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
\GetIdInfo$Id: l3file.dtx 3095 2011-12-26 22:33:23Z joseph $
  {L3 Experimental file operations}
\ProvidesExplPackage
  {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\package_check_loaded_expl:
\tl_new:N \g_file_current_name_tl
\tl_gset_eq:NN \g_file_current_name_tl \@currname
\seq_new:N \g_file_stack_seq
\seq_new:N \g_file_record_seq
\tl_new:N \l_file_name_tl
\seq_new:N \l_file_search_path_seq
\seq_new:N \l_file_search_path_saved_seq
\seq_new:N \l_file_tmpa_seq
\cs_new_protected:Npn \file_add_path:nN #1#2
  {
    \ior_open:Nn \g_file_test_ior {#1}
    \ior_if_eof:NTF \g_file_test_ior
      { \file_add_path_search:nN {#1} #2 }
      {
        \ior_close:N \g_file_test_ior
        \tl_set:Nx #2 {#1}
      }
  }
\cs_new_protected:Npn \file_add_path_search:nN #1#2
  {
    \tl_clear:N #2
    \cs_if_exist:NT \input@path
      {
        \seq_set_eq:NN \l_file_search_path_saved_seq \l_file_search_path_seq
        \seq_set_from_clist:NN \l_file_tmpa_seq \input@path
        \seq_concat:NNN \l_file_search_path_seq
          \l_file_search_path_seq \l_file_tmpa_seq
      }
    \seq_map_inline:Nn \l_file_search_path_seq
      {
        \ior_open:Nn \g_file_test_ior { ##1 #1 }
        \ior_if_eof:NF \g_file_test_ior
          {
            \tl_set:Nx #2 { ##1 #1 }
            \seq_map_break:
          }
      }
    \cs_if_exist:NT \input@path
      { \seq_set_eq:NN \l_file_search_path_seq \l_file_search_path_saved_seq }
    \ior_close:N \g_file_test_ior
  }
\prg_new_protected_conditional:Nnn \file_if_exist:n { T , F , TF }
  {
    \file_add_path:nN {#1} \l_file_name_tl
    \tl_if_empty:NTF \l_file_name_tl
      { \prg_return_false: }
      { \prg_return_true: }
  }
\cs_new_protected:Npn \file_input:n #1
  {
    \file_add_path:nN {#1} \l_file_name_tl
    \tl_if_empty:NF \l_file_name_tl
      {
        \@addtofilelist {#1}
        \seq_gpush:NV \g_file_stack_seq \g_file_current_name_tl
        \tl_gset:Nn \g_file_current_name_tl {#1}
        \exp_after:wN \tex_input:D \l_file_name_tl \c_space_tl
        \seq_gpop:NN \g_file_stack_seq \g_file_current_name_tl
      }
  }
\cs_new_protected:Npn \file_path_include:n #1
  {
    \seq_if_in:NnF  \l_file_search_path_seq {#1}
      { \seq_put_right:Nn \l_file_search_path_seq {#1} }
  }
\cs_new_protected:Npn \file_path_remove:n #1
  { \seq_remove_all:Nn \l_file_search_path_seq {#1} }
\cs_new_protected_nopar:Npn \file_list:
  {
    \seq_remove_duplicates:N \g_file_record_seq
    \iow_log:n { *~File~List~* }
    \seq_map_inline:Nn \g_file_record_seq { \iow_log:n {##1} }
    \iow_log:n { ************* }
  }
\AtBeginDocument
  {
    \seq_set_from_clist:NN \l_file_tmpa_seq \@filelist
    \seq_gconcat:NNN \g_file_record_seq \g_file_record_seq \l_file_tmpa_seq
  }
%% 
%%
%% End of file `l3file.sty'.