Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.5.0 - Português

Change language to:
English - Français - 日本語 - Русский

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function

Ajuda do Scilab >> Arquivos : funções de Entrada/Saída > Paths - Filenames > pathconvert

pathconvert

converts a path to an OS path format.

Calling Sequence

paths = pathconvert(paths [,flagtrail [,flagexpand [,type]]])

Arguments

paths

a string matrix giving a set of file paths

flagtrail

optional boolean, used to add a trailing file separator to the paths (\ or /, depending on the target path format). Default value is true (%t).

flagexpand

optional boolean, used to expand leading variables in paths. Default value is true (%t).

type

optional string, used to specify the target path format: 'u' for POSIX path format (GNU/Linux,...), and 'w' for Windows path format.

Description

pathconvert is used to convert a set of paths, to be compatible with an OS (Operating System) path format. For example Windows path style uses / for file separator, while it is \ on other OS.

By default, the paths are converted to the current OS path format (but another path format can be specified with argument type).

Note: Windows paths starting with a drive letter prefix are converted to the POSIX paths using the cygwin convention (with /cygdrive). For example: C:\tmp will be converted to /cygdrive/C/tmp.

flagtrail is used to add or remove a file separator (depending on the target path format) to the end of paths. When the parameter is set to true, a trailing file separator is added if missing. Otherwise, the trailing file separators are removed.

flagexpand is used to expand the leading Scilab environment variables in paths. The following variables are accepted:

  • SCI
  • WSCI
  • SCIHOME
  • TMPDIR
  • home (or ~)
WSCI is unknown on GNU/Linux and ~ in term "path" is unknown on Windows.

Examples

pathconvert("SCI/modules/foo", %f, %t, "w")
pathconvert("SCI\modules\foo", %f, %t, "u")
pathconvert("SCI\modules\foo", %t, %t, "u")
pathconvert("SCI/modules/foo", %f, %f, "w")
pathconvert("SCI/modules/foo", %t, %f, "w")
pathconvert("C:/tmp", %f, %f, "u")
pathconvert("/cygdrive/c/tmp", %f, %f, "w")

See Also

  • basename — strip directory and suffix from filenames
  • listfiles — list of files
  • dirname — gets directory from filenames
Report an issue
<< is_absolute_path Paths - Filenames pathsep >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Fri Apr 11 14:18:14 CEST 2014