%%
%% 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 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 ``expl3 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 LaTeX Project Team.
%%
%% -----------------------------------------------------------------------
%%
\RequirePackage{l3names}
\GetIdInfo$Id: l3file.dtx 1352 2009-05-28 11:50:39Z morten $
  {L3 Experimental file loading}
\ProvidesExplPackage
  {\filename}{\filedate}{\fileversion}{\filedescription}
\package_check_loaded_expl:
\clist_new:N \g_file_record_clist
\clist_new:N \g_file_record_full_clist
\clist_new:N \l_file_search_path_clist
\ior_new:N \l_file_test_read_stream
\bool_new:N \l_file_tmp_bool
\tl_new:N \l_file_tmp_tl
\prg_new_conditional:Nnn \file_if_exist:n {p,TF,T,F} {
  \ior_open:Nn \l_file_test_read_stream {#1}
  \ior_if_eof:NTF \l_file_test_read_stream {
    \file_if_exist_path:n {#1}
  }{
    \ior_close:N \l_file_test_read_stream
    \prg_return_true:
  }
}
\cs_new_nopar:Nn \file_if_exist_path:n {
  \bool_set_false:N \l_file_tmp_bool
  \cs_set_nopar:Nn \file_if_exist_aux:n {
    \ior_open:Nn \l_file_test_read_stream { #1 ##1 }
    \ior_if_eof:NF \l_file_test_read_stream {
      \bool_set_true:N \l_file_tmp_bool
      \clist_map_break:
    }
  }
  \cs_if_exist:NT \input@path {
    \cs_set_eq:NN \l_file_search_path_clist \input@path
  }
  \clist_map_function:NN \l_file_search_path_clist \file_if_exist_aux:n
  \ior_close:N \l_file_test_read_stream
  \bool_if:NTF \l_file_tmp_bool {
    \prg_return_true:
  }{
    \prg_return_false:
  }
}
\cs_new_nopar:Nn \file_if_exist_aux:n { }
\cs_new_nopar:Nn \file_add_path:nN {
  \tl_clear:N #2
  \ior_open:Nn \l_file_test_read_stream {#1}
  \ior_if_eof:NTF \l_file_test_read_stream {
    \file_add_path_search:nN {#1} #2
  }{
    \tl_set:Nn #2 {#1}
  }
  \ior_close:N \l_file_test_read_stream
}
\cs_new_nopar:Nn \file_add_path_search:nN {
  \cs_set_nopar:Nn \file_add_path_aux:n {
    \ior_open:Nn \l_file_test_read_stream { ##1 #1 }
    \ior_if_eof:NF \l_file_test_read_stream {
      \tl_set:Nn #2 { ##1 #1 }
      \clist_map_break:
    }
  }
  \cs_if_exist:NT \input@path {
    \cs_set_eq:NN \l_file_search_path_clist \input@path
  }
  \clist_map_function:NN \l_file_search_path_clist \file_add_path_aux:n
}
\cs_new_nopar:Nn \file_add_path_aux:n { }
\cs_new:Nn \file_input:n {
  \file_add_path:nN {#1} \l_file_tmp_tl
  \tl_if_empty:NF \l_file_tmp_tl {
    \file_input_no_check:n \l_file_tmp_tl
  }
}
\cs_new:Nn \file_input_no_record:n {
  \file_add_path:nN {#1} \l_file_tmp_tl
  \tl_if_empty:NF \l_file_tmp_tl {
    \file_input_no_check_no_record:n \l_file_tmp_tl
  }
}
\cs_new_nopar:Nn \file_input_no_check:n {
  \clist_gput_right:Nx \g_file_record_clist {#1}
  \wlog{ADDING: #1}
  \@addtofilelist {#1}
  \clist_gput_right:Nx \g_file_record_full_clist {#1}
  \tex_input:D #1 ~
}
\cs_new_nopar:Nn \file_input_no_check_no_record:n {
  \clist_gput_right:Nx \g_file_record_full_clist {#1}
  \tex_input:D #1 ~
}
\cs_new_nopar:Nn \file_list: {
  \file_list:N \g_file_record_clist
}
\cs_new_nopar:Nn \file_list_full: {
  \file_list:N \g_file_record_full_clist
}
\cs_new_nopar:Nn \file_list:N {
  \clist_remove_duplicates:N #1
  \iow_log:x { *~File~List~* }
  \clist_map_function:NN #1 \file_list_aux:n
  \iow_log:x { ************* }
}
\cs_new_nopar:Nn \file_list_aux:n {
  \iow_log:x { #1 }
}
\AtBeginDocument{
  \clist_put_right:NV \g_file_record_clist \@filelist
  \clist_put_right:NV \g_file_record_full_clist \@filelist
}
%% 
%%
%% End of file `l3file.sty'.
