summaryrefslogtreecommitdiff
path: root/demo.cc
diff options
context:
space:
mode:
Diffstat (limited to 'demo.cc')
-rw-r--r--demo.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/demo.cc b/demo.cc
index 542db5e..62bdeed 100644
--- a/demo.cc
+++ b/demo.cc
@@ -1,7 +1,38 @@
+#include <cstdlib>
#include <dux/io.h>
#include <dux/thr.h>
#include <iostream>
int main() {
::std::cout << "dux " << dux_api << '.' << dux_ext << ", demo" << ::std::endl;
+
+ ::dux_err err = ::dux_err_oky;
+
+ auto const chkerr = [&err](char const * const msg) noexcept {
+ if (err != ::dux_err_oky) {
+ ::std::cout << msg << ": " << ::dux_errmsg(err) << ::std::endl;
+ ::std::exit(EXIT_FAILURE);
+ }
+ };
+
+ err = ::dux_crtdir("testdir",0755u);
+ chkerr("unable to create directory");
+
+ ::dux_fil * fil = nullptr;
+
+ err = ::dux_crt(&fil,"testdir/dux-demo-file",0644u);
+ chkerr("unable to create file");
+
+ err = ::dux_wrtstr(fil,
+ "static void msg(void);\n"
+ "\n"
+ "int main(void) {\n"
+ "\tmsg();\n"
+ "\treturn 0x45;\n"
+ "}\n"
+ );
+ chkerr("unable to write to file");
+
+ err = ::dux_cls(fil);
+ chkerr("unable to close file");
}