diff --git a/bin/uce_fastcgi.debug.linux.bin b/bin/uce_fastcgi.debug.linux.bin index 8acd07f..1fb5c2f 100755 Binary files a/bin/uce_fastcgi.debug.linux.bin and b/bin/uce_fastcgi.debug.linux.bin differ diff --git a/doc/areas/sys.txt b/doc/areas/sys.txt index b1a1ec9..b264b58 100644 --- a/doc/areas/sys.txt +++ b/doc/areas/sys.txt @@ -3,6 +3,7 @@ System Functions basename dirname expand_path +file_append file_exists file_get_contents file_mtime @@ -10,6 +11,7 @@ file_put_contents get_cwd ls mkdir +print set_cwd shell_escape shell_exec diff --git a/doc/pages/file_append.txt b/doc/pages/file_append.txt new file mode 100644 index 0000000..82fce57 --- /dev/null +++ b/doc/pages/file_append.txt @@ -0,0 +1,12 @@ +:sig +void file_append(String file_name, ...val) + +:params +file_name : file name of file that should be written to +...val : one or more values that should be written into the file + +:desc +Opens or creates a given file and appends data to it. + +:see +>sys diff --git a/doc/pages/print.txt b/doc/pages/print.txt new file mode 100644 index 0000000..f263e35 --- /dev/null +++ b/doc/pages/print.txt @@ -0,0 +1,11 @@ +:sig +void print(...val) + +:params +...val : one or more values that should be output + +:desc +Appends data to the current request's output stream. + +:see +>sys diff --git a/src/lib/sys.h b/src/lib/sys.h index 0b2cb1f..07db8f5 100644 --- a/src/lib/sys.h +++ b/src/lib/sys.h @@ -8,6 +8,16 @@ bool mkdir(String path); bool file_exists(String path); String file_get_contents(String file_name); bool file_put_contents(String file_name, String content); +#include +template +bool file_append(String file_name, Ts... args) +{ + std::ofstream fout; + fout.open(file_name.c_str(), std::ios_base::app); + ((fout << args), ...); + fout.close(); + return(true); +} String get_cwd(); void set_cwd(String path); time_t file_mtime(String file_name); diff --git a/test/file_append.uce b/test/file_append.uce new file mode 100644 index 0000000..c9adf67 --- /dev/null +++ b/test/file_append.uce @@ -0,0 +1,36 @@ + + + + +RENDER() +{ + DTree t; + + <> + +

+ UCE Test: + File Append +

+ + File Append: + +
get["cmd"] == "clear")
+				file_put_contents("/tmp/test.txt", "");
+
+			file_append("/tmp/test.txt", context->server->request_count, "\thello world\t", 2, "\t", time(), "\t", microtime(), "\n");
+
+			print(file_get_contents("/tmp/test.txt"));
+
+		?>
+ + + + + Params +
params) ?>
+ + +} diff --git a/test/index.uce b/test/index.uce index ea1d3d4..4270828 100644 --- a/test/index.uce +++ b/test/index.uce @@ -25,6 +25,7 @@ RENDER()
  • Memcached
  • MySQL Connector
  • File I/O
  • +
  • File Append
  • RNG/Noise
  • Task API