aboutsummaryrefslogtreecommitdiff
path: root/std/os
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-02-03 11:51:29 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-02-03 11:51:29 -0500
commitabf5ae6897bb23e49e4232ab8be7ed61ea9520b6 (patch)
treea0ff1d117e79a63827995c65d22a3fc4e46a37e1 /std/os
parentb8f59e14cdbf90cf724ed9e721c1909293f41b3b (diff)
downloadzig-abf5ae6897bb23e49e4232ab8be7ed61ea9520b6.tar.gz
zig-abf5ae6897bb23e49e4232ab8be7ed61ea9520b6.zip
*WIP* error sets - support fns called at comptime
Diffstat (limited to 'std/os')
-rw-r--r--std/os/child_process.zig12
-rw-r--r--std/os/index.zig4
2 files changed, 10 insertions, 6 deletions
diff --git a/std/os/child_process.zig b/std/os/child_process.zig
index c86db9d69c..48f638e323 100644
--- a/std/os/child_process.zig
+++ b/std/os/child_process.zig
@@ -28,7 +28,7 @@ pub const ChildProcess = struct {
pub stdout: ?io.File,
pub stderr: ?io.File,
- pub term: ?%Term,
+ pub term: ?SpawnError!Term,
pub argv: []const []const u8,
@@ -54,6 +54,10 @@ pub const ChildProcess = struct {
err_pipe: if (is_windows) void else [2]i32,
llnode: if (is_windows) void else LinkedList(&ChildProcess).Node,
+ pub const SpawnError = error {
+
+ };
+
pub const Term = union(enum) {
Exited: i32,
Signal: i32,
@@ -185,7 +189,7 @@ pub const ChildProcess = struct {
/// Spawns a child process, waits for it, collecting stdout and stderr, and then returns.
/// If it succeeds, the caller owns result.stdout and result.stderr memory.
pub fn exec(allocator: &mem.Allocator, argv: []const []const u8, cwd: ?[]const u8,
- env_map: ?&const BufMap, max_output_size: usize) %ExecResult
+ env_map: ?&const BufMap, max_output_size: usize) !ExecResult
{
const child = try ChildProcess.init(argv, allocator);
defer child.deinit();
@@ -246,7 +250,7 @@ pub const ChildProcess = struct {
fn waitUnwrappedWindows(self: &ChildProcess) !void {
const result = os.windowsWaitSingle(self.handle, windows.INFINITE);
- self.term = (%Term)(x: {
+ self.term = (SpawnError!Term)(x: {
var exit_code: windows.DWORD = undefined;
if (windows.GetExitCodeProcess(self.handle, &exit_code) == 0) {
break :x Term { .Unknown = 0 };
@@ -631,7 +635,7 @@ pub const ChildProcess = struct {
};
fn windowsCreateProcess(app_name: &u8, cmd_line: &u8, envp_ptr: ?&u8, cwd_ptr: ?&u8,
- lpStartupInfo: &windows.STARTUPINFOA, lpProcessInformation: &windows.PROCESS_INFORMATION) %void
+ lpStartupInfo: &windows.STARTUPINFOA, lpProcessInformation: &windows.PROCESS_INFORMATION) !void
{
if (windows.CreateProcessA(app_name, cmd_line, null, null, windows.TRUE, 0,
@ptrCast(?&c_void, envp_ptr), cwd_ptr, lpStartupInfo, lpProcessInformation) == 0)
diff --git a/std/os/index.zig b/std/os/index.zig
index a303ee4be1..aad24cf996 100644
--- a/std/os/index.zig
+++ b/std/os/index.zig
@@ -1072,7 +1072,7 @@ pub fn changeCurDir(allocator: &Allocator, dir_path: []const u8) !void {
}
/// Read value of a symbolic link.
-pub fn readLink(allocator: &Allocator, pathname: []const u8) ![]u8 {
+pub fn readLink(allocator: &Allocator, pathname: []const u8) error![]u8 {
const path_buf = try allocator.alloc(u8, pathname.len + 1);
defer allocator.free(path_buf);
@@ -1267,7 +1267,7 @@ pub const ArgIteratorWindows = struct {
}
/// You must free the returned memory when done.
- pub fn next(self: &ArgIteratorWindows, allocator: &Allocator) ?internalNext.errors![]u8 {
+ pub fn next(self: &ArgIteratorWindows, allocator: &Allocator) ?(@typeOf(internalNext).ReturnType.ErrorSet![]u8) {
// march forward over whitespace
while (true) : (self.index += 1) {
const byte = self.cmd_line[self.index];