add svn_runner module
This commit is contained in:
parent
bb20d3bf38
commit
8b85b70ea9
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/Build/
|
||||
/.rscons*
|
||||
/build/
|
||||
/svi
|
||||
|
10
Rsconscript
Normal file
10
Rsconscript
Normal file
@ -0,0 +1,10 @@
|
||||
configure do
|
||||
check_d_compiler
|
||||
end
|
||||
|
||||
build do
|
||||
Environment.new do |env|
|
||||
env["D_IMPORT_PATH"] << "src"
|
||||
env.Program("svi", glob("src/**/*.d"))
|
||||
end
|
||||
end
|
8
src/main.d
Normal file
8
src/main.d
Normal file
@ -0,0 +1,8 @@
|
||||
import svn_runner;
|
||||
import std.stdio;
|
||||
|
||||
int main(string[] args)
|
||||
{
|
||||
auto r = run_svn(["ls", "https://vcs.gentex.com/svn/embedded_sw"]);
|
||||
return 0;
|
||||
}
|
36
src/svn_runner.d
Normal file
36
src/svn_runner.d
Normal file
@ -0,0 +1,36 @@
|
||||
import std.process;
|
||||
import std.stdio;
|
||||
|
||||
struct Result
|
||||
{
|
||||
int status;
|
||||
char[] stdout;
|
||||
char[] stderr;
|
||||
}
|
||||
|
||||
private File nullfd()
|
||||
{
|
||||
return File("/dev/null", "r");
|
||||
}
|
||||
|
||||
Result run_svn(string[] args)
|
||||
{
|
||||
string[] command = ["svn", "--non-interactive", "--no-auth-cache"] ~ args;
|
||||
auto stdout_pipe = pipe();
|
||||
auto stderr_pipe = pipe();
|
||||
auto pid = spawnProcess(command, nullfd(), stdout_pipe.writeEnd,
|
||||
stderr_pipe.writeEnd);
|
||||
char[] stdout;
|
||||
char[] stderr;
|
||||
char[] buf;
|
||||
while (stdout_pipe.readEnd.readln(buf))
|
||||
{
|
||||
stdout ~= buf;
|
||||
}
|
||||
while (stderr_pipe.readEnd.readln(buf))
|
||||
{
|
||||
stderr ~= buf;
|
||||
}
|
||||
int status = wait(pid);
|
||||
return Result(status, stdout, stderr);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user