File System
gkScript main object
The global gkScript object offers the following filesystem functions:
class gkScript
{
...
// Local filesystem
bool loadFile(string path, string content);
bool loadFile(string path, string content, size_t offset, size_t size);
string readStdin();
bool saveFile(string path, string content, bool overwrite = false);
bool saveFile(string path, string content, size_t offset);
bool setFileSize(string path, size_t size);
bool setFileAttributes(string path, int attributes);
bool copyFile(string sourcePath, string targetPath, bool overwrite);
bool moveFile(string sourcePath, string targetPath);
bool deleteFile(string path, bool recycleBin = false);
bool createDirectory(string path);
bool deleteDirectory(string path);
vector<DirectoryEntry> listDirectory(string path);
bool getFileInformation(string path, DirectoryEntry &info);
map<string, value> getFileSummary(string path);
map<string, string> enumDrives();
bool addNetworkConnection(string path, string user, string password, string localDrive = "");
bool deleteNetworkConnection(string path, bool force = false);
...
};
Directory Content
DirectoryEntry:
class DirectoryEntry
{
isFolder; // bool
name; // string
path; // string
attributes; // uint32_t
size; // int64_t
created, modified; // time_t
}
listDirectory sample:
eval> var list=gkScript.listDirectory("c:");
eval> for (entry : list){print(entry.name);}
$Recycle.Bin
$WINDOWS.~BT
bootmgr
BOOTNXT
Config.Msi
Documents and Settings
MATS
OneDriveTemp
pagefile.sys
PerfLogs
Program Files
Program Files (x86)
ProgramData
Recovery
swapfile.sys
System Volume Information
Users
Windows
Ranged read/write operations
File summary
Dump MSI installer cache:
var dir=gkScript.listDirectory(gkScript.expandString("%windir%\\installer"));
var i=0;
for (entry : dir) {
if (!entry.isFolder) {
var info=gkScript.getFileSummary(entry.path);
if (!is_var_undef(info["MSI Package Code"])) {
++i;
print(entry.name + " (" + entry.path + ")");
print(" Package Code " + to_string(info["MSI Package Code"]));
if (!is_var_undef(info["Subject"])) {print(" " + to_string(info["Subject"]));}
}
}
}
print(to_string(i) + " Packages found.");
Read console input
Console input sample:
>echo Hello %username%|chaiCmd.exe -c "var in=gkScript.readStdin(); print(\"input: \" + in);"
input: Hello christoph
Read console input
Last updated