 }
 
 
+/** Error type for file commands. */
+public enum FileError: ErrorProtocol {
+
+	case notFound (path: String)
+
+	public static func checkFile (_ path: String) throws {
+		if !Files.fileExists(atPath: path) {
+			throw notFound(path: path)
+		}
+	}
+}
+
+extension FileError: CustomStringConvertible {
+	public var description: String {
+		switch self {
+		case .notFound(let path):
+			return "Error: '\(path)' does not exist."
+		}
+	}
+}
+
 /** Open a file for reading, throw if an error occurs. */
 public func open (_ path: String, encoding: NSStringEncoding = main.encoding) throws -> ReadableStream {
 	return try open(NSURL(fileURLWithPath: path, isDirectory: false), encoding: encoding)


/** Open a file for reading, throw if an error occurs. */
public func open (_ path: NSURL, encoding: NSStringEncoding = main.encoding) throws -> ReadableStream {
	return ReadableStream(try NSFileHandle(forReadingFrom: path), encoding: encoding)
}

/**

		Files.createFile(atPath: path.path!, contents: nil, attributes: nil)
	}

	do {
		let filehandle = try NSFileHandle(forWritingTo: path)
		filehandle.seekToEndOfFile()
		return WriteableStream(filehandle, encoding: encoding)
	} catch {
		try FileError.checkFile(path.path!)
		throw error
	}
}

/**
