Vim documentation: vital/System/Filepath

main help file
vital/System/Filepath.txt             path string utilities library.

Maintainer: thinca  <thinca+vim@gmail.com>
            tyru    <tyru.exe@gmail.com>

==============================================================================
CONTENTS                                Vital.System.Filepath-contents

INTRODUCTION                    Vital.System.Filepath-introduction
INTERFACE                       Vital.System.Filepath-interface
  Functions                       Vital.System.Filepath-functions

==============================================================================
INTRODUCTION                            Vital.System.Filepath-introduction

Vital.System.Filepath is Path String Utilities Library.
It provides some functions to manipulate path strings.

==============================================================================
INTERFACE                               Vital.System.Filepath-interface
------------------------------------------------------------------------------
FUNCTIONS                               Vital.System.Filepath-functions

to_slash({path})                        Vital.System.Filepath.to_slash()
        Use when you quote path string for scripting languages, without
        worrying about the runtime operating system is if windows or not.

        e.g.

        let code = printf(
          \ '(neoclojure-init "%s")',
          \ shellescape(s:F.to_slash(path)))
        ..
        let path = s:F.from_slash(
          \ s:get_path_like_string_from_something())


        This function intentionally ignores 'shellslash' option, so that you
        can simply use this function for path string not only from Vim but
        also from others, such as environment vars, problem output, or really
        anything.
        See also: Vital.System.Filepath.from_slash()

from_slash({path})                      Vital.System.Filepath.from_slash()
        This is opposite to Vital.System.Filepath.to_slash(). See its doc.

separator()                     Vital.System.Filepath.separator()
        Return OS related directory separator as string.
        This returns "/" on non-Windows, or Windows and 'shellslash' is on.
        This returns "\" on Windows and 'shellslash' is off.

path_separator()                Vital.System.Filepath.path_separator()
        Return OS related path separator as string.
        This returns ";" on Windows.
        Otherwise this returns ":".

        You can get list of each filepath of $PATH by:

        split($PATH, s:F.path_separator())

path_extensions()               Vital.System.Filepath.path_extensions()
        Return OS related path extensions as array of string.

unify_separator({path})         Vital.System.Filepath.unify_separator()
        Return path string replaced all directory separators with '/'.

which({command} [, {path}])     Vital.System.Filepath.which()
        Returns the full path of {command}.  This searches from {path} or
        $PATH.  If the command is not found, returns empty string.

split({path})                   Vital.System.Filepath.split()
        Return List of elements in {path} string.

join({args}...)                 Vital.System.Filepath.join()
        Join the path in {args}.

is_absolute({path})             Vital.System.Filepath.is_absolute()
        When {path} is absolute path, return 1.
        Otherwise, return 0.
        cf. Vital.System.Filepath.is_relative()

is_relative({path})             Vital.System.Filepath.is_relative()
        When {path} is relative path, return 1.
        Otherwise, return 0.
        cf. Vital.System.Filepath.is_absolute()

dirname({path})                 Vital.System.Filepath.dirname()
        Return directory name from {path}.

basename({path})                Vital.System.Filepath.basename()
        Return basename from {path}.

remove_last_separator({path})   Vital.System.Filepath.remove_last_separator()
        Remove last directory separator if exists.

is_case_tolerant()              Vital.System.Filepath.is_case_tolerant()
        Return non-zero if filesystem ignores alphabetic case of a filename,
        zero otherwise.

expand_home({path})             Vital.System.Filepath.expand_home()
        Return a home-expanded path of {path}.  The home directory expansion
        will not have a trailing directory separator.

        Like expand(), but only expanding a leading "~" home directory
        sequence, or like fnamemodify() with the ":p" modifier, but without
        full path expansion or unpredictable results if a file name doesn't
        exist and doesn't have an absolute path.  See filename-modifiers.

abspath({path})                 Vital.System.Filepath.abspath()
        Return an absolute path of {path}.
        If the {path} is already an absolute path, it returns the {path}.
        cf. Vital.System.Filepath.relpath()

relpath({path})                 Vital.System.Filepath.relpath()
        Return a relative path of {path}.
        If the {path} is already a relative path, it returns the {path}.
        cf. Vital.System.Filepath.abspath()

unixpath({path})                Vital.System.Filepath.unixpath()
        Return a unix path of {path}.
        All backslashes (\) in {path} will be substituted to slashes (/).

winpath({path})                 Vital.System.Filepath.winpath()
        Return a windows path of {path}.
        All slashes (/) in {path} will be substituted to backslashes (\).

realpath({path})                Vital.System.Filepath.realpath()
        Return a real path of {path} of the current operation system.
        In non Windows OS, it calls Vital.System.Filepath.unixpath()
        internally.
        In windows, it calls Vital.System.Filepath.unixpath() when the
        Vim is compiled with '+shellslash' and shellslash is specified.
        Otherwise it calls Vim.System.Filepath.winpath() internally.

is_root_directory({path})       Vital.System.Filepath.is_root_directory()
        Return 1 if the given {path} points to the root directory, otherwise
        0.

        is_root_directory('/') == 1
        is_root_directory('/aaa') == 0
        is_root_directory('/aaa/..') == 0 " It doesn't resolve.
        is_root_directory('C:/') == 1     " If it's on Windows.

contains({path}, {base})        Vital.System.Filepath.contains()
        Return 1 if {path} contains {base}, otherwise 0.
        {path} and {base} must be a full path.

        contains('/foo/bar/buz', '/foo/bar') == 1
        contains('/foo/hoge/buz', '/foo/bar') == 0



==============================================================================
vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl

top - main help file - tag index