-
-
Notifications
You must be signed in to change notification settings - Fork 5
File IO
Nenkai edited this page Jul 14, 2024
·
7 revisions
Warning
This API was introduced after GT4.
if (pdistd::ReadFile(path))
{
// File exists
}
var st = main::pdistd::ReadFile(path);
if (st["result"] == pdistd::FileError::OK)
{
var buf = st["buffer"];
// Do something with the buffer...
}
var str = "hello";
if (pdistd::WriteFile(path, str))
{
// ...
}
var st = pdistd::GetFileStatus(path);
st["result"] // Result
st["size"] // File Size
st["_time"] // Datetime
var files = pdistd::GetFileEntries(dir);
if (files == nil)
return;
foreach (var file in files)
{
var is_dir = entry["type"] == "DIRECTORY";
var is_file = entry["type"] == "REGULAR";
// ...
}
pdistd::MakeDirectory(dir, recursive);
pdistd::MakeDirectoryForFile(file_path);
pdistd::CopyFile(source, destination);
pdistd::RemoveFile(file);
pdistd::RemoveDirectory(directory, true); // second argument is recursive.
var size_left = pdistd::GetDiskFreeSize(path);