Beispiel #1
0
static int os_remove (lua_State *L) {
  const char *filename = luaL_checkstring(L, 1);
#ifdef WIN32
  wchar_t wfilename[MAX_PATH+1];
  MultiByteToWideChar(CP_UTF8, 0, filename, -1, wfilename, MAX_PATH+1);
  return os_pushresult(L, _wremove(wfilename), filename);
#else
  // FIXME: non-win32 conversion to local filesystem encoding?
  return os_pushresult(L, remove(filename) == 0, filename);
#endif
}
Beispiel #2
0
static int os_remove (lua_State *L) {
  const char *filename = luaL_checkstring(L, 1);
  if (!G(L)->remove_func) { /* SPRING */
    lua_pushnil(L);
    lua_pushliteral(L, "os.remove() is not available");
    lua_pushnumber(L, 0);
    return 3;
  }
  return os_pushresult(L, G(L)->remove_func(L, filename) == 0, filename);
}
static int os_rename (lua_State *L) {
  const char *fromname = luaL_checkstring(L, 1);
  const char *toname = luaL_checkstring(L, 2);
  return os_pushresult(L, rename(fromname, toname) == 0, fromname);
}
static int os_remove (lua_State *L) {
  const char *filename = luaL_checkstring(L, 1);
  return os_pushresult(L, remove(filename) == 0, filename);
}