static class · System.IO
File
public static class File
- Tipo
- static class
- Espacio de nombres
- System.IO
- Ensamblado
- System.Core
- Acceso
- public, static, abstract
- Archivo fuente
IO.ant
Herencia
- Clases base
-
AnyFile
Métodos
ReadAllText(str path) : str
#
WriteAllText(str path, str text)
#
AppendAllText(str path, str text)
#
Delete(str path)
#
When the file was last written, in milliseconds since 1970 (UTC).
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
File en Antril, descompilado a partir de su Larva HIR.
// System.IO.File — System.Core (decompiled from Larva HIR)
import System;
import System.Text;
into namespace System.IO
{
public static class File
{
extern("file.read") ReadInto(u16[] path) : i64;
extern("file.take") TakeInto(u8[] bytes);
extern("file.write") WriteFrom(u16[] path, u8[] bytes, i64 append) : i64;
extern("file.kind") KindOf(u16[] path) : i64;
extern("file.delete") DeleteAt(u16[] path) : i64;
extern("file.time") TimeOf(u16[] path) : i64;
public:
Exists(str path) : bool => KindOf(Unicode.ToUtf16(path)) == 1;
ReadAllBytes(str path) : u8[]
{
i64 size = ReadInto(Unicode.ToUtf16(path));
if (size < 0)
throw new IOError("cannot read " + path);
u8[] bytes = new u8[(i32)size];
TakeInto(bytes);
return bytes;
}
ReadAllText(str path) : str => Encoding.UTF8.GetString(ReadAllBytes(path));
ReadAllLines(str path) : List<str> => ReadAllText(path).Lines();
WriteAllBytes(str path, u8[] bytes)
{
if (WriteFrom(Unicode.ToUtf16(path), bytes, 0) != 0)
throw new IOError("cannot write " + path);
}
WriteAllText(str path, str text)
{
WriteAllBytes(path, Encoding.UTF8.GetBytes(text));
}
AppendAllText(str path, str text)
{
if (WriteFrom(Unicode.ToUtf16(path), Encoding.UTF8.GetBytes(text), 1) != 0)
throw new IOError("cannot write " + path);
}
WriteAllLines(str path, List<str> lines)
{
StringBuilder text = new StringBuilder();
{
ListIterator<str> _iterator1 = lines.Iterator();
loop (_iterator1.Next())
{
str line = _iterator1.Current;
text.AppendLine(line);
}
}
WriteAllText(path, text.ToString());
}
Delete(str path)
{
if (DeleteAt(Unicode.ToUtf16(path)) != 0 && KindOf(Unicode.ToUtf16(path)) != 0)
throw new IOError("cannot delete " + path);
}
/// When the file was last written, in milliseconds since 1970 (UTC).
GetLastWriteTime(str path) : i64
{
i64 time = TimeOf(Unicode.ToUtf16(path));
if (time < 0)
throw new IOError("no file " + path);
return time;
}
}
}