diff options
Diffstat (limited to 'MCServer/Plugins')
-rw-r--r-- | MCServer/Plugins/APIDump/APIDesc.lua | 4 | ||||
-rw-r--r-- | MCServer/Plugins/Debuggers/Debuggers.lua | 47 | ||||
-rw-r--r-- | MCServer/Plugins/Debuggers/Info.lua | 2 | ||||
-rw-r--r-- | MCServer/Plugins/DumpInfo/Init.lua | 13 | ||||
-rw-r--r-- | MCServer/Plugins/InfoDump.lua | 7 |
5 files changed, 61 insertions, 12 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 9ee818a2c..025e9470d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -973,11 +973,15 @@ cFile:Delete("/usr/bin/virus.exe"); ]], Functions = { + ChangeFileExt = { Params = "FileName, NewExt", Return = "string", Notes = "(STATIC) Returns FileName with its extension changed to NewExt. NewExt may begin with a dot, but needn't, the result is the same in both cases (the first dot, if present, is ignored). FileName may contain path elements, extension is recognized as the last dot after the last path separator in the string." }, Copy = { Params = "SrcFileName, DstFileName", Return = "bool", Notes = "(STATIC) Copies a single file to a new destination. Returns true if successful. Fails if the destination already exists." }, CreateFolder = { Params = "FolderName", Return = "bool", Notes = "(STATIC) Creates a new folder. Returns true if successful." }, Delete = { Params = "FileName", Return = "bool", Notes = "(STATIC) Deletes the specified file. Returns true if successful." }, Exists = { Params = "FileName", Return = "bool", Notes = "(STATIC) Returns true if the specified file exists." }, + GetExecutableExt = { Params = "", Return = "string", Notes = "(STATIC) Returns the customary executable extension (including the dot) used by the current platform (\".exe\" on Windows, empty string on Linux). " }, GetFolderContents = { Params = "FolderName", Return = "array table of strings", Notes = "(STATIC) Returns the contents of the specified folder, as an array table of strings. Each filesystem object is listed. Use the IsFile() and IsFolder() functions to determine the object type." }, + GetLastModificationTime = { Params = "Path", Return = "number", Notes = "(STATIC) Returns the last modification time (in current timezone) of the specified file or folder. Returns zero if file not found / not accessible. The returned value is in the same units as values returned by os.time()." }, + GetPathSeparator = { Params = "", Return = "string", Notes = "(STATIC) Returns the primary path separator used by the current platform. Returns \"\\\" on Windows and \"/\" on Linux. Note that the platform or CRT may support additional path separators, those are not reported." }, GetSize = { Params = "FileName", Return = "number", Notes = "(STATIC) Returns the size of the file, or -1 on failure." }, IsFile = { Params = "Path", Return = "bool", Notes = "(STATIC) Returns true if the specified path points to an existing file." }, IsFolder = { Params = "Path", Return = "bool", Notes = "(STATIC) Returns true if the specified path points to an existing folder." }, diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index d0c362ab4..01a5de81e 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -9,7 +9,7 @@ g_ShowFoodStats = false; -- When true, each player's food stats are sent to the -function Initialize(Plugin) +function Initialize(a_Plugin) --[[ -- Test multiple hook handlers: cPluginManager.AddHook(cPluginManager.HOOK_TICK, OnTick1); @@ -45,14 +45,12 @@ function Initialize(Plugin) -- Bind all the console commands: RegisterPluginInfoConsoleCommands(); - Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers) - Plugin:AddWebTab("StressTest", HandleRequest_StressTest) + a_Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers) + a_Plugin:AddWebTab("StressTest", HandleRequest_StressTest) -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); - LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) - -- TestBlockAreas() -- TestSQLiteBindings() -- TestExpatBindings() @@ -62,6 +60,11 @@ function Initialize(Plugin) TestStringBase64() -- TestUUIDFromName() -- TestRankMgr() + TestFileExt() + TestFileLastMod() + + local LastSelfMod = cFile:GetLastModificationTime(a_Plugin:GetLocalFolder() .. "/Debuggers.lua") + LOG("Debuggers.lua last modified on " .. os.date("%Y-%m-%dT%H:%M:%S", LastSelfMod)) --[[ -- Test cCompositeChat usage in console-logging: @@ -79,6 +82,40 @@ end; +function TestFileExt() + assert(cFile:ChangeFileExt("fileless_dir/", "new") == "fileless_dir/") + assert(cFile:ChangeFileExt("fileless_dir/", ".new") == "fileless_dir/") + assert(cFile:ChangeFileExt("pathless_file.ext", "new") == "pathless_file.new") + assert(cFile:ChangeFileExt("pathless_file.ext", ".new") == "pathless_file.new") + assert(cFile:ChangeFileExt("path/to/file.ext", "new") == "path/to/file.new") + assert(cFile:ChangeFileExt("path/to/file.ext", ".new") == "path/to/file.new") + assert(cFile:ChangeFileExt("path/to.dir/file", "new") == "path/to.dir/file.new") + assert(cFile:ChangeFileExt("path/to.dir/file", ".new") == "path/to.dir/file.new") + assert(cFile:ChangeFileExt("path/to.dir/file.ext", "new") == "path/to.dir/file.new") + assert(cFile:ChangeFileExt("path/to.dir/file.ext", ".new") == "path/to.dir/file.new") + assert(cFile:ChangeFileExt("path/to.dir/file.longext", "new") == "path/to.dir/file.new") + assert(cFile:ChangeFileExt("path/to.dir/file.longext", ".new") == "path/to.dir/file.new") + assert(cFile:ChangeFileExt("path/to.dir/file.", "new") == "path/to.dir/file.new") + assert(cFile:ChangeFileExt("path/to.dir/file.", ".new") == "path/to.dir/file.new") +end + + + + + +function TestFileLastMod() + local f = assert(io.open("test.txt", "w")) + f:write("test") + f:close() + local filetime = cFile:GetLastModificationTime("test.txt") + local ostime = os.time() + LOG("file time: " .. filetime .. ", OS time: " .. ostime .. ", difference: " .. ostime - filetime) +end + + + + + function TestPluginCalls() -- In order to test the inter-plugin communication, we're going to call Core's ReturnColorFromChar() function -- It is a rather simple function that doesn't need any tables as its params and returns a value, too diff --git a/MCServer/Plugins/Debuggers/Info.lua b/MCServer/Plugins/Debuggers/Info.lua index 0370145df..2e170487b 100644 --- a/MCServer/Plugins/Debuggers/Info.lua +++ b/MCServer/Plugins/Debuggers/Info.lua @@ -28,7 +28,7 @@ g_PluginInfo = Handler = HandleCompo, HelpString = "Tests the cCompositeChat bindings" }, - ["/cs"] = + ["/cstay"] = { Permission = "debuggers", Handler = HandleChunkStay, diff --git a/MCServer/Plugins/DumpInfo/Init.lua b/MCServer/Plugins/DumpInfo/Init.lua index 5d9c752b0..1faa8d60f 100644 --- a/MCServer/Plugins/DumpInfo/Init.lua +++ b/MCServer/Plugins/DumpInfo/Init.lua @@ -28,17 +28,18 @@ function HandleDumpPluginRequest(a_Request) Content = Content .. [[ <table> -<th colspan="2">DumpInfo</th>]] + <tr> + <th colspan="2">DumpInfo</th> + </tr>]] -- Loop through each plugin that is found. for PluginName, k in pairs(cPluginManager:Get():GetAllPlugins()) do - -- Check if there is a file called 'Info.lua' or 'info.lua' if (cFile:Exists("Plugins/" .. PluginName .. "/Info.lua")) then - Content = Content .. "<tr>" - Content = Content .. "<td>" .. PluginName .. "</td>" - Content = Content .. "<td> <form method='POST'> <input type='hidden' value='" .. PluginName .. "' name='DumpInfo'> <input type='submit' value='DumpInfo'> </form>" - Content = Content .. "</td>" + Content = Content .. "\n<tr>\n" + Content = Content .. "\t<td>" .. PluginName .. "</td>\n" + Content = Content .. "\t<td><form method='POST'> <input type='hidden' value='" .. PluginName .. "' name='DumpInfo'> <input type='submit' value='DumpInfo'></form></td>\n" + Content = Content .. "</tr>\n" end end diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 07a534b88..ab4dfd861 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -18,6 +18,13 @@ only that one plugin's documentation. This mode of operation doesn't require Lua +-- If this file is called using the loadfile function the arg variable isn't filled. We have to do it manualy then. +local arg = arg or {...} + + + + + -- Check Lua version. We use 5.1-specific construct when loading the plugin info, 5.2 is not compatible! if (_VERSION ~= "Lua 5.1") then print("Unsupported Lua version. This script requires Lua version 5.1, this Lua is version " .. (_VERSION or "<nil>")) |