Added missing os_copyfile.c (doh!)

This commit is contained in:
starkos 2009-01-08 19:30:57 +00:00
parent 4797c6d4bb
commit 29f6048b6c

34
src/host/os_copyfile.c Normal file
View File

@ -0,0 +1,34 @@
/**
* \file os_copyfile.c
* \brief Copy a file from one location to another.
* \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
*/
#include "premake.h"
int os_copyfile(lua_State* L)
{
int z;
const char* src = luaL_checkstring(L, 1);
const char* dst = luaL_checkstring(L, 2);
#if PLATFORM_WINDOWS
z = CopyFile(src, dst, FALSE);
#else
luaL_pushfstring(L, "cp %s %s", src, dst);
z = (system(lua_tostring(L, -1)) == 0);
#endif
if (!z)
{
lua_pushnil(L);
lua_pushfstring(L, "unable to copy file to '%s'", dst);
return 2;
}
else
{
lua_pushboolean(L, 1);
return 1;
}
}