๐งฉ IO Guide
July 25, 2025 ยท View on GitHub
๐ Quick Start Guide for file and folder operations with LuaDoTheWorld
๐ What You'll Learn
- โ How to load and write files
- โ How to copy and move files or folders (overwrite or merge)
๐ ๏ธ Prerequisites
- LuaDoTheWorld installed and required in your script
๐ Load a File
local dtw = require("luaDoTheWorld/luaDoTheWorld")
local content = dtw.load_file("tests/target/a.txt")
print(content)
๐ Write a File
local dtw = require("luaDoTheWorld/luaDoTheWorld")
dtw.write_file("tests/target/b.txt", "text content")
๐ Copy Anything (Overwrite)
This will copy a file or folder, overwriting whatever is at the destination.
local dtw = require("luaDoTheWorld/luaDoTheWorld")
dtw.copy_any_overwriting("tests/target/test_dir", "tests/target/a")
๐ Copy Anything (Merge)
This will copy and merge folders if the destination is a folder.
local dtw = require("luaDoTheWorld/luaDoTheWorld")
dtw.copy_any_merging("tests/target/test_dir", "tests/target/a")
๐ Move Anything (Overwrite)
This will move a file or folder, removing the destination if it exists.
local dtw = require("luaDoTheWorld/luaDoTheWorld")
dtw.move_any_overwriting("tests/target/test_dir", "tests/target/a")
๐ Move Anything (Merge)
This will move and merge folders if the destination is a folder.
local dtw = require("luaDoTheWorld/luaDoTheWorld")
dtw.move_any_merging("tests/target/test_dir", "tests/target/a")
๐ Quick Reference
| Function | What it does | Example |
|---|---|---|
dtw.load_file(path) | Load file content | dtw.load_file("a.txt") |
dtw.write_file(path, data) | Write content to file | dtw.write_file("b.txt", "text") |
dtw.copy_any_overwriting(src, dest) | Copy and overwrite | dtw.copy_any_overwriting("dir", "a") |
dtw.copy_any_merging(src, dest) | Copy and merge | dtw.copy_any_merging("dir", "a") |
dtw.move_any_overwriting(src, dest) | Move and overwrite | dtw.move_any_overwriting("dir", "a") |
dtw.move_any_merging(src, dest) | Move and merge | dtw.move_any_merging("dir", "a") |
๐ Need Help?
- ๐ Check the main SDK documentation
- ๐ Look at other example scripts in the SDK
- ๐ Report issues on our GitHub repository