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
Any File

Métodos

Exists(str path) : bool
#

static

ReadAllBytes(str path) : u8[]
#

static

ReadAllText(str path) : str
#

static

ReadAllLines(str path) : List<str>
#

static

WriteAllBytes(str path, u8[] bytes)
#

static

WriteAllText(str path, str text)
#

static

AppendAllText(str path, str text)
#

static

WriteAllLines(str path, List<str> lines)
#

static

Delete(str path)
#

static

GetLastWriteTime(str path) : i64
#

static

When the file was last written, in milliseconds since 1970 (UTC).

Miembros privados e internos (6)

extern("file.read") ReadInto(u16[] path) : i64
#

private static

extern("file.take") TakeInto(u8[] bytes)
#

private static

extern("file.write") WriteFrom(u16[] path, u8[] bytes, i64 append) : i64
#

private static

extern("file.kind") KindOf(u16[] path) : i64
#

private static

extern("file.delete") DeleteAt(u16[] path) : i64
#

private static

extern("file.time") TimeOf(u16[] path) : i64
#

private static

Miembros heredados (5)

Código fuente

File en Antril, descompilado a partir de su Larva HIR.

System.IO.File.ant
// 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;
			}
	}
}
Esc