static class · System.IO
Directory
public static class Directory
- Tipo
- static class
- Espacio de nombres
- System.IO
- Ensamblado
- System.Core
- Acceso
- public, static, abstract
- Archivo fuente
IO.ant
Herencia
- Clases base
-
AnyDirectory
Métodos
CreateDirectory(str path)
#
Makes the folder (and the folders above it that are missing).
The names of the folder's entries (files and folders), sorted.
The full paths of the files in the folder.
Delete(str path)
#
Takes out an empty folder.
Miembros privados e internos (6)
Miembros heredados (5)
GetTypemétodo de AnyUndescribedmétodo de AnyToStringmétodo de AnyHashmétodo de Anydestroymétodo de Any
Código fuente
Directory en Antril, descompilado a partir de su Larva HIR.
// System.IO.Directory — System.Core (decompiled from Larva HIR)
import System;
into namespace System.IO
{
public static class Directory
{
extern("dir.create") CreateAt(u16[] path) : i64;
extern("dir.list") ListInto(u16[] path) : i64;
extern("dir.length") EntryLength(i64 index) : i64;
extern("dir.unit") EntryUnit(i64 index, i64 at) : i64;
extern("file.kind") KindOf(u16[] path) : i64;
extern("file.delete") DeleteAt(u16[] path) : i64;
public:
Exists(str path) : bool => KindOf(Unicode.ToUtf16(path)) == 2;
/// Makes the folder (and the folders above it that are missing).
CreateDirectory(str path)
{
if (CreateAt(Unicode.ToUtf16(path)) != 0 && KindOf(Unicode.ToUtf16(path)) != 2)
throw new IOError("cannot make the folder " + path);
}
/// The names of the folder's entries (files and folders), sorted.
GetEntries(str path) : List<str>
{
i64 count = ListInto(Unicode.ToUtf16(path));
if (count < 0)
throw new IOError("cannot list " + path);
List<str> names = new List<str>((i32)count);
loop (i64 i = 0..count)
{
u16[] units = new u16[(i32)EntryLength(i)];
loop (i32 j = 0..units.Length)
units[j] = (u16)EntryUnit(i, j);
names.Add(Unicode.FromUtf16(units));
}
return names;
}
/// The full paths of the files in the folder.
GetFiles(str path) : List<str>
{
List<str> files = new List<str>();
{
ListIterator<str> _iterator1 = GetEntries(path).Iterator();
loop (_iterator1.Next())
{
str name = _iterator1.Current;
{
str full = Path.Combine(path, name);
if (KindOf(Unicode.ToUtf16(full)) == 1)
files.Add(full);
}
}
}
return files;
}
/// Takes out an empty folder.
Delete(str path)
{
if (DeleteAt(Unicode.ToUtf16(path)) != 0)
throw new IOError("cannot delete the folder " + path);
}
}
}