///////////////////////////////////////////////////////////////////////////////
//                            Lisaac OS Library                              //
//                                                                           //
//                   LSIIT - ULP - CNRS - INRIA - FRANCE                     //
//                                                                           //
//   This program is free software: you can redistribute it and/or modify    //
//   it under the terms of the GNU General Public License as published by    //
//   the Free Software Foundation, either version 3 of the License, or       //
//   (at your option) any later version.                                     //
//                                                                           //
//   This program is distributed in the hope that it will be useful,         //
//   but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//   GNU General Public License for more details.                            //
//                                                                           //
//   You should have received a copy of the GNU General Public License       //
//   along with this program.  If not, see <http://www.gnu.org/licenses/>.   //
//                                                                           //
//                     http://isaacproject.u-strasbg.fr/                     //
///////////////////////////////////////////////////////////////////////////////
Section Header
  
  + name        :=FILE_SYSTEM;

  - copyright   := "2003-2005 Jérome Boutet, 2003-2007 Benoit Sonntag";

  - comment     :="File System manager for Unix.";
  
  - external := `#include <unistd.h>`; // For `getcwd'
  
Section Inherit  
  
  + parent_directory:DIRECTORY <-
  ( + cwd:NATIVE_ARRAY[CHARACTER];
    + root:ENTRY;
    + result:DIRECTORY;
    
    string_tmp.clear;
    cwd := string_tmp.to_external;
    `getcwd(@cwd,255)`;
    string_tmp.from_external cwd;
    
    ABSTRACT_ENTRY.reduce_path string_tmp;
    root := ENTRY.get_entry string_tmp;
    ? {root != NULL};
    (root = NULL).if {
    //  STD_ERROR.put_string "FATAL ERROR: root directory `";
    //  STD_ERROR.put_string string_tmp;
    //  STD_ERROR.put_string "' not found.";
      "FILE_SYSTEM : Error Root 1\n".print;
      OBJECT.die_with_code (OBJECT.exit_failure_code);
    };
    root := root.open;
    
    ? {root != NULL};
    (root = NULL).if {
      //STD_ERROR.put_string "FATAL ERROR: root directory `";
      //STD_ERROR.put_string string_tmp;
      //STD_ERROR.put_string "' not open.";
      "FILE_SYSTEM : Error root 2\n".print;
      OBJECT.die_with_code (OBJECT.exit_failure_code);
    };
    result ?= root;
    ? {result != NULL};
    parent_directory := result
  );
  
Section Private  
  
  - string_tmp:STRING := STRING.create 255; 
  
Section ISAAC
  
  - make <-
  // Isaac compatibility.
  (
    // Nothing.
  );
  


