2015-11-25 04:51:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Andrew Kelley
|
|
|
|
*
|
|
|
|
* This file is part of zig, which is MIT licensed.
|
|
|
|
* See http://opensource.org/licenses/MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZIG_OS_HPP
|
|
|
|
#define ZIG_OS_HPP
|
|
|
|
|
|
|
|
#include "list.hpp"
|
|
|
|
#include "buffer.hpp"
|
2017-03-14 01:11:55 +08:00
|
|
|
#include "error.hpp"
|
2015-11-25 04:51:36 +08:00
|
|
|
|
2015-12-01 10:58:53 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2016-05-08 10:58:02 +08:00
|
|
|
enum TerminationId {
|
|
|
|
TerminationIdClean,
|
|
|
|
TerminationIdSignaled,
|
|
|
|
TerminationIdStopped,
|
|
|
|
TerminationIdUnknown,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Termination {
|
|
|
|
TerminationId how;
|
|
|
|
int code;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-02-18 06:56:06 +08:00
|
|
|
void os_init(void);
|
2016-05-08 10:58:02 +08:00
|
|
|
void os_spawn_process(const char *exe, ZigList<const char *> &args, Termination *term);
|
2016-02-18 06:56:06 +08:00
|
|
|
int os_exec_process(const char *exe, ZigList<const char *> &args,
|
2016-05-08 10:58:02 +08:00
|
|
|
Termination *term, Buf *out_stderr, Buf *out_stdout);
|
2015-11-25 04:51:36 +08:00
|
|
|
|
2016-04-19 06:47:21 +08:00
|
|
|
void os_path_dirname(Buf *full_path, Buf *out_dirname);
|
2015-11-25 10:07:33 +08:00
|
|
|
void os_path_split(Buf *full_path, Buf *out_dirname, Buf *out_basename);
|
2017-03-31 17:48:15 +08:00
|
|
|
void os_path_extname(Buf *full_path, Buf *out_basename, Buf *out_extname);
|
2015-12-01 10:58:53 +08:00
|
|
|
void os_path_join(Buf *dirname, Buf *basename, Buf *out_full_path);
|
2015-12-16 12:48:41 +08:00
|
|
|
int os_path_real(Buf *rel_path, Buf *out_abs_path);
|
2016-04-19 06:47:21 +08:00
|
|
|
void os_path_resolve(Buf *ref_path, Buf *target_path, Buf *out_abs_path);
|
|
|
|
bool os_path_is_absolute(Buf *path);
|
2015-11-25 10:07:33 +08:00
|
|
|
|
2015-11-26 16:29:52 +08:00
|
|
|
void os_write_file(Buf *full_path, Buf *contents);
|
2017-04-11 18:14:46 +08:00
|
|
|
int os_copy_file(Buf *src_path, Buf *dest_path);
|
2015-11-26 16:29:52 +08:00
|
|
|
|
2015-12-01 10:58:53 +08:00
|
|
|
int os_fetch_file(FILE *file, Buf *out_contents);
|
|
|
|
int os_fetch_file_path(Buf *full_path, Buf *out_contents);
|
|
|
|
|
|
|
|
int os_get_cwd(Buf *out_cwd);
|
|
|
|
|
2015-12-01 15:50:11 +08:00
|
|
|
bool os_stderr_tty(void);
|
|
|
|
|
2016-01-27 15:01:49 +08:00
|
|
|
int os_buf_to_tmp_file(Buf *contents, Buf *suffix, Buf *out_tmp_path);
|
|
|
|
int os_delete_file(Buf *path);
|
|
|
|
|
2017-03-14 01:11:55 +08:00
|
|
|
int os_file_exists(Buf *full_path, bool *result);
|
|
|
|
|
2017-04-20 02:00:12 +08:00
|
|
|
int os_rename(Buf *src_path, Buf *dest_path);
|
2017-04-26 00:29:25 +08:00
|
|
|
double os_get_time(void);
|
2017-04-20 02:00:12 +08:00
|
|
|
|
2017-04-05 19:46:50 +08:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
#define ZIG_OS_DARWIN
|
|
|
|
#elif defined(_WIN32)
|
|
|
|
#define ZIG_OS_WINDOWS
|
|
|
|
#elif defined(__linux__)
|
|
|
|
#define ZIG_OS_LINUX
|
|
|
|
#else
|
|
|
|
#define ZIG_OS_UNKNOWN
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__x86_64__)
|
|
|
|
#define ZIG_ARCH_X86_64
|
|
|
|
#else
|
|
|
|
#define ZIG_ARCH_UNKNOWN
|
|
|
|
#endif
|
|
|
|
|
2015-11-25 04:51:36 +08:00
|
|
|
#endif
|