static class · System.IO
Directory
public static class Directory
- Kind
- static class
- Namespace
- System.IO
- Assembly
- System.Core
- Access
- public, static, abstract
- Source file
IO.ant
Inheritance
- Base classes
-
AnyDirectory
Methods
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.
Private and internal members (6)
Inherited members (5)
GetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
Directory as Antril, decompiled from its 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);
}
}
}