Decompile fn_18339 (LuaChangeDirectoryOfDatas)

Batch #1623 by eAthena: 0 byte-identical, 1 confirmed by peer review.

- fn_18339 LuaChangeDirectoryOfDatas: logic confirmed by peer review

Reviewed-by: ragnarok-clanker
Adds to the build: Source/Script/LuaFileOperations.cpp
This commit is contained in:
ragnarok-clanker 2026-10-28 19:45:29 +00:00
commit ef5ff48035
3 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,28 @@
#include "Script/LuaFileOperations.h"
#include "File/FileCreation.h"
extern "C" {
#include <lauxlib.h>
}
#include <cstdio>
#include <io.h>
#include <string>
// OFFSET: 0x00AFE7D0
// FUNCTION: fn_18339
int LuaChangeDirectoryOfDatas(lua_State* state) {
std::string name = luaL_checkstring(state, 1);
std::string sourceDirectory = luaL_checkstring(state, 2);
std::string targetDirectory = luaL_checkstring(state, 3);
std::string source = sourceDirectory + "\\" + name;
std::string target = targetDirectory + "\\" + name;
if (_access(target.c_str(), 0) != 0 && _access(source.c_str(), 0) == 0) {
if (_access(target.c_str(), 0) == 0 || CreateDirectoryPath(targetDirectory)) {
std::rename(source.c_str(), target.c_str());
}
}
return 0;
}

View file

@ -0,0 +1,8 @@
#ifndef RAGNAROK_SOURCE_SCRIPT_LUAFILEOPERATIONS_H
#define RAGNAROK_SOURCE_SCRIPT_LUAFILEOPERATIONS_H
struct lua_State;
int LuaChangeDirectoryOfDatas(lua_State* state);
#endif