Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

io/dir/make.fz


# This file is part of the Fuzion language implementation.
#
# The Fuzion language implementation 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, version 3 of the License.
#
# The Fuzion language implementation 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 The
# Fuzion language implementation.  If not, see <https://www.gnu.org/licenses/>.


# -----------------------------------------------------------------------
#
#  Tokiwa Software GmbH, Germany
#
#  Source code of Fuzion standard library feature dir.make
#
# -----------------------------------------------------------------------

# make -- effect providing make directory
#
public make(fwh Make_Dir_Handler, _ unit) : effect is

  # makes a directory using the specified path
  # parent directories in the path should exist otherwise, no creation will take place and an error will be the outcome
  # in case of successful creation a unit type will be the outcome
  #
  make_dir(
             # the (relative or absolute) dir name, using platform specific path separators
             path String) =>
    replace
    fwh.mkdir path


  # the default handler
  #
  type.default_handler =>
    ref : io.dir.Make_Dir_Handler is
      public redef mkdir(path String) outcome unit =>
        fuzion.sys.fileio.create_dir path


# make dir with the currently installed dir.make-effect.
#
# if none is installed the default handler will be used to
# install the effect and perform the operation.
#
public make(path String) outcome unit =>
  if !io.dir.make.is_instated
    (io.dir.make make.default_handler unit).default
  make.env.make_dir path


# reference to the writing operations that could take place
#
public Make_Dir_Handler ref is
  public mkdir(path String) outcome unit => abstract

last changed: 2025-06-17