PreviousUpNext

15.4.1168  src/lib/std/src/posix/winix-path.pkg

## winix-path.pkg       Portable file paths.

# Compiled by:
#     src/lib/std/src/standard-core.sublib

# The UNIX implementation of winix::path
# providing portable (cross-platform)
# support for manipulation of hierarchical
# file paths.
#
# This is a subpackage of winix_guts:
#
#     src/lib/std/src/posix/winix-guts.pkg


package winix_path
=
winix_path_g (                  # winix_path_g  def in    src/lib/std/src/winix/winix-path-g.pkg
  package {

    exception PATH;

    Arc_Kind = NULL | PARENT | CURRENT | ARC  String;

    fun ilkify ""   => NULL;
        ilkify "."  => CURRENT;
        ilkify ".." => PARENT;
        ilkify a    => ARC a;
    end;

    parent_arc
        =
        "..";

    current_arc
        =
        ".";

    fun volume_is_valid (_, disk_volume)
        =
        substring::is_empty disk_volume;

    vol_ss
        =
        substring::from_string "";

                                                # inline_t              is from   src/lib/core/init/built-in.pkg

    #  Note: we are guaranteed that this is never called with "" 
    #
    fun split_vol_path s
        =
        if (inline_t::vector_of_chars::get_byte_as_char (s, 0) == '/')
            #            
            (TRUE,  vol_ss, substring::drop_first 1 (substring::from_string s));
        else
            (FALSE, vol_ss, substring::from_string s);
        fi;

    fun join_vol_path (TRUE, "", "") =>  "/";
        join_vol_path (TRUE, "",  s) =>  "/" + s;
        join_vol_path (FALSE, "", s) =>  s;
        join_vol_path _              =>  raise exception PATH;             #  invalid disk_volume 
    end;

    arc_sep_char
        =
        '/';

    fun same_vol (v1, v2: String)
        =
        v1 == v2;

  });



## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext