Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstarkos <none@none>2009-03-26 02:04:32 +0300
committerstarkos <none@none>2009-03-26 02:04:32 +0300
commit0776e56996fa3f25d4f746bd05e3b6badc339644 (patch)
treeea6684aac212f4e1ec9fe879f7067e90a090f66a /src/base/io.lua
parentd61caeb2c8758558969876e1d507d3f73efbfc31 (diff)
** Merged branches/platforms (r735:741) Added x32 and x64 platform support for VS2005 and 2008
Diffstat (limited to 'src/base/io.lua')
-rw-r--r--src/base/io.lua67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/base/io.lua b/src/base/io.lua
new file mode 100644
index 0000000..948784e
--- /dev/null
+++ b/src/base/io.lua
@@ -0,0 +1,67 @@
+--
+-- io.lua
+-- Additions to the I/O namespace.
+-- Copyright (c) 2008-2009 Jason Perkins and the Premake project
+--
+
+
+--
+-- Prepare to capture the output from all subsequent calls to io.printf(),
+-- used for automated testing of the generators.
+--
+
+ function io.capture()
+ io.captured = ''
+ end
+
+
+
+--
+-- Returns the captured text and stops capturing.
+--
+
+ function io.endcapture()
+ local captured = io.captured
+ io.captured = nil
+ return captured
+ end
+
+
+--
+-- Open an overload of the io.open() function, which will create any missing
+-- subdirectories in the filename if "mode" is set to writeable.
+--
+
+ local builtin_open = io.open
+ function io.open(fname, mode)
+ if (mode) then
+ if (mode:find("w")) then
+ local dir = path.getdirectory(fname)
+ ok, err = os.mkdir(dir)
+ if (not ok) then
+ error(err, 0)
+ end
+ end
+ end
+ return builtin_open(fname, mode)
+ end
+
+
+
+--
+-- A shortcut for printing formatted output to an output stream.
+--
+
+ function io.printf(msg, ...)
+ if (not io.eol) then
+ io.eol = "\n"
+ end
+
+ local s = string.format(msg, unpack(arg))
+ if io.captured then
+ io.captured = io.captured .. s .. io.eol
+ else
+ io.write(s)
+ io.write(io.eol)
+ end
+ end