summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2015-06-16 22:10:43 +0800
committerruki <[email protected]>2015-06-16 22:10:43 +0800
commit8c8d7af7135b400a44cc58d3f0d74a72164f9b2a (patch)
treec491d0d3cd0f512b5c5e916f20264b3e7603f69e /core/src
parent3d97768287a089f862d841cb697b48852941b002 (diff)
check for the mtime of project file
Diffstat (limited to 'core/src')
-rwxr-xr-xcore/src/xmake/machine.c2
-rwxr-xr-xcore/src/xmake/makefile1
-rwxr-xr-xcore/src/xmake/os/mtime.c55
3 files changed, 58 insertions, 0 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c
index 018020b5c..0898f9807 100755
--- a/core/src/xmake/machine.c
+++ b/core/src/xmake/machine.c
@@ -56,6 +56,7 @@ tb_int_t xm_os_rmdir(lua_State* lua);
tb_int_t xm_os_mkdir(lua_State* lua);
tb_int_t xm_os_cpdir(lua_State* lua);
tb_int_t xm_os_chdir(lua_State* lua);
+tb_int_t xm_os_mtime(lua_State* lua);
tb_int_t xm_os_curdir(lua_State* lua);
tb_int_t xm_os_tmpdir(lua_State* lua);
tb_int_t xm_os_isfile(lua_State* lua);
@@ -88,6 +89,7 @@ static luaL_Reg const g_os_functions[] =
, { "mkdir", xm_os_mkdir }
, { "cpdir", xm_os_cpdir }
, { "chdir", xm_os_chdir }
+, { "mtime", xm_os_mtime }
, { "curdir", xm_os_curdir }
, { "tmpdir", xm_os_tmpdir }
, { "isfile", xm_os_isfile }
diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile
index 932737fe8..3cb152e16 100755
--- a/core/src/xmake/makefile
+++ b/core/src/xmake/makefile
@@ -20,6 +20,7 @@ xmake_C_FILES += \
os/mkdir \
os/cpdir \
os/chdir \
+ os/mtime \
os/curdir \
os/tmpdir \
os/isfile \
diff --git a/core/src/xmake/os/mtime.c b/core/src/xmake/os/mtime.c
new file mode 100755
index 000000000..623cdbd56
--- /dev/null
+++ b/core/src/xmake/os/mtime.c
@@ -0,0 +1,55 @@
+/*!The Automatic Cross-platform Build Tool
+ *
+ * XMake is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * XMake is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with XMake;
+ * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+ *
+ * Copyright (C) 2009 - 2015, ruki All rights reserved.
+ *
+ * @author ruki
+ * @file mtime.c
+ *
+ */
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * trace
+ */
+#define TB_TRACE_MODULE_NAME "mtime"
+#define TB_TRACE_MODULE_DEBUG (0)
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * implementation
+ */
+tb_int_t xm_os_mtime(lua_State* lua)
+{
+ // check
+ tb_assert_and_check_return_val(lua, 0);
+
+ // get the path
+ tb_char_t const* path = luaL_checkstring(lua, 1);
+ tb_check_return_val(path, 0);
+
+ // done os.mtime(path)
+ tb_file_info_t info = {0};
+ if (tb_file_info(path, &info) && (info.type == TB_FILE_TYPE_FILE))
+ lua_pushinteger(lua, (lua_Integer)info.mtime);
+ else lua_pushinteger(lua, 0);
+
+ // ok
+ return 1;
+}