%%
%% 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 "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 LaTeX3 Project.
%%
%% -----------------------------------------------------------------------
\RequirePackage{l3names}
\GetIdInfo$Id: l3file.dtx 2665 2011-08-25 22:15:27Z 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
\cs_new_protected_nopar:Npn \file_add_path:nN #1#2
  {
    \ior_open:Nn \g_file_test_stream {#1}
    \ior_if_eof:NTF \g_file_test_stream
      { \file_add_path_search:nN {#1} #2 }
      {
        \ior_close:N \g_file_test_stream
        \tl_set:Nx #2 {#1}
      }
  }
\cs_new_protected_nopar: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
        \clist_map_inline:Nn \input@path
          { \seq_put_right:Nn \l_file_search_path_seq {##1} }
      }
    \seq_map_inline:Nn \l_file_search_path_seq
      {
        \ior_open:Nn \g_file_test_stream { ##1 #1 }
        \ior_if_eof:NF \g_file_test_stream
          {
            \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_stream
  }
\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_nopar: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 ~
        \seq_gpop:NN \g_file_stack_seq \g_file_current_name_tl
      }
  }
\cs_new_protected_nopar: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_nopar: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
  {
    \clist_map_inline:Nn \@filelist
      { \seq_put_right:Nn \g_file_record_seq {#1} }
  }
%% 
%%
%% End of file `l3file.sty'.
