static class · System.IO
Path
public static class Path
Paths as text: '/' and '' both separate folders.
- Tipo
- static class
- Espacio de nombres
- System.IO
- Ensamblado
- System.Core
- Acceso
- public, static, abstract
- Archivo fuente
IO.ant
Herencia
- Clases base
-
AnyPath
Propiedades
Métodos
Combine(str first, str second) : str
#
Combine(str first, str second, str third) : str
#
GetFileName(str path) : str
#
GetExtension(str path) : str
#
The extension with its point ("" when there is none).
GetFileNameWithoutExtension(str path) : str
#
GetDirectoryName(str path) : str
#
The folder part ("" when there is none).
ChangeExtension(str path, str extension) : str
#
Miembros privados e internos (2)
Miembros heredados (5)
GetTypemétodo de AnyUndescribedmétodo de AnyToStringmétodo de AnyHashmétodo de Anydestroymétodo de Any
Código fuente
Path en Antril, descompilado a partir de su Larva HIR.
// System.IO.Path — System.Core (decompiled from Larva HIR)
into namespace System.IO
{
/// Paths as text: '/' and '\' both separate folders.
public static class Path
{
IsSeparator(u8 c) : bool => c == 47 || c == 92;
/// Where the file name starts.
NameStart(str path) : i32
{
i32 i = path.Length - 1;
loop (i >= 0 && !IsSeparator(path[i]) && path[i] != 58)
i--;
return i + 1;
}
public:
Combine(str first, str second) : str
{
if (first.Length == 0 || second.Length > 0 && (IsSeparator(second[0]) || second.Length > 1 && second[1] == 58))
return second;
return IsSeparator(first[first.Length - 1]) ? first + second : first + "/" + second;
}
Combine(str first, str second, str third) : str => Combine(Combine(first, second), third);
GetFileName(str path) : str => path.Substring(NameStart(path));
/// The extension with its point ("" when there is none).
GetExtension(str path) : str
{
str name = GetFileName(path);
i32 dot = name.LastIndexOf(46);
return dot <= 0 ? "" : name.Substring(dot);
}
GetFileNameWithoutExtension(str path) : str
{
str name = GetFileName(path);
i32 dot = name.LastIndexOf(46);
return dot <= 0 ? name : name.Substring(0, dot);
}
/// The folder part ("" when there is none).
GetDirectoryName(str path) : str
{
i32 start = NameStart(path);
if (start == 0)
return "";
return start == 1 ? path.Substring(0, 1) : path.Substring(0, start - 1);
}
ChangeExtension(str path, str extension) : str
{
i32 start = NameStart(path);
i32 dot = GetFileName(path).LastIndexOf(46);
str stem = dot <= 0 ? path : path.Substring(0, start + dot);
if (extension.Length == 0)
return stem;
return extension[0] == 46 ? stem + extension : stem + "." + extension;
}
HasExtension(str path) : bool => GetExtension(path).Length > 0;
u8 DirectorySeparatorChar
{
get => 47;
}
}
}