From ad57ce5f9940ab2776d9a3ad6dafe86b07d23058 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 26 Sep 2015 22:54:18 +0200 Subject: Extended and fixed the cFile API. --- Server/Plugins/APIDump/APIDesc.lua | 12 ++++++++---- Server/Plugins/APIDump/main_APIDump.lua | 8 +++----- Server/Plugins/Core | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) (limited to 'Server/Plugins') diff --git a/Server/Plugins/APIDump/APIDesc.lua b/Server/Plugins/APIDump/APIDesc.lua index 187c72b9e..65aef9e4e 100644 --- a/Server/Plugins/APIDump/APIDesc.lua +++ b/Server/Plugins/APIDump/APIDesc.lua @@ -1008,16 +1008,20 @@ local Hash = cCryptoHash.sha1HexString("DataToHash") Provides helper functions for manipulating and querying the filesystem. Most functions are static, so they should be called directly on the cFile class itself:
-cFile:Delete("/usr/bin/virus.exe");
+cFile:DeleteFile("/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." }, + CreateFolder = { Params = "FolderPath", Return = "bool", Notes = "(STATIC) Creates a new folder. Returns true if successful. Only a single level can be created at a time, use CreateFolderRecursive() to create multiple levels of folders at once." }, + CreateFolderRecursive = { Params = "FolderPath", Return = "bool", Notes = "(STATIC) Creates a new folder, creating its parents if needed. Returns true if successful." }, + Delete = { Params = "Path", Return = "bool", Notes = "(STATIC) Deletes the specified file or folder. Returns true if successful. Only deletes folders that are empty.
NOTE: If you already know if the object is a file or folder, use DeleteFile() or DeleteFolder() explicitly." }, + DeleteFile = { Params = "FilePath", Return = "bool", Notes = "(STATIC) Deletes the specified file. Returns true if successful." }, + DeleteFolder = { Params = "FolderPath", Return = "bool", Notes = "(STATIC) Deletes the specified file or folder. Returns true if successful. Only deletes folders that are empty." }, + DeleteFolderContents = { Params = "FolderPath", Return = "bool", Notes = "(STATIC) Deletes everything from the specified folder, recursively. The specified folder stays intact. Returns true if successful." }, + Exists = { Params = "Path", Return = "bool", Notes = "(STATIC) Returns true if the specified file or folder exists.
OBSOLETE, use IsFile() or IsFolder() instead" }, 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()." }, diff --git a/Server/Plugins/APIDump/main_APIDump.lua b/Server/Plugins/APIDump/main_APIDump.lua index c0685087a..fd2b0e786 100644 --- a/Server/Plugins/APIDump/main_APIDump.lua +++ b/Server/Plugins/APIDump/main_APIDump.lua @@ -174,11 +174,9 @@ local function WriteArticles(f) ]]); for _, extra in ipairs(g_APIDesc.ExtraPages) do local SrcFileName = g_PluginFolder .. "/" .. extra.FileName; - if (cFile:Exists(SrcFileName)) then + if (cFile:IsFile(SrcFileName)) then local DstFileName = "API/" .. extra.FileName; - if (cFile:Exists(DstFileName)) then - cFile:Delete(DstFileName); - end + cFile:Delete(DstFileName); cFile:Copy(SrcFileName, DstFileName); f:write("
  • " .. extra.Title .. "
  • \n"); else @@ -1112,7 +1110,7 @@ local function ListMissingPages() local NumLinks = 0; for PageName, Referrers in pairs(g_TrackedPages) do NumLinks = NumLinks + 1; - if not(cFile:Exists("API/" .. PageName .. ".html")) then + if not(cFile:IsFile("API/" .. PageName .. ".html")) then table.insert(MissingPages, {Name = PageName, Refs = Referrers} ); end end; diff --git a/Server/Plugins/Core b/Server/Plugins/Core index ee01115ac..b1e3f972e 160000 --- a/Server/Plugins/Core +++ b/Server/Plugins/Core @@ -1 +1 @@ -Subproject commit ee01115ac848116cf58956fa6d031dbbadddba0a +Subproject commit b1e3f972ebf475bfbe1dfc8bccc0240977d11d3e -- cgit v1.2.3