mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-30 21:23:00 +00:00 
			
		
		
		
	Merge branch 'mc-1.20.x' into mc-1.21.x
Oh, I'm sure I missed something here. This was a nasty merge, has the docs have changed so much in each version.
This commit is contained in:
		| @@ -13,7 +13,7 @@ import java.util.Set; | ||||
|  * This is intended for logging errors where the message content is supplied from untrusted sources. This isn't a | ||||
|  * perfect escaping mechanism, but ensures basic "unsafe" strings (i.e. ANSI escape sequences, long lines) are escaped. | ||||
|  * | ||||
|  * <h2>Example:</h2> | ||||
|  * <h2>Example</h2> | ||||
|  * <pre>{@code | ||||
|  * LOG.error("Some error occurred: {}", new TruncatedError(error)); | ||||
|  * }</pre> | ||||
|   | ||||
| @@ -223,16 +223,21 @@ end | ||||
| --- Returns true if a path is mounted to the parent filesystem. | ||||
| -- | ||||
| -- The root filesystem "/" is considered a mount, along with disk folders and | ||||
| -- the rom folder. Other programs (such as network shares) can exstend this to | ||||
| -- make other mount types by correctly assigning their return value for getDrive. | ||||
| -- the rom folder. | ||||
| -- | ||||
| -- @tparam string path The path to check. | ||||
| -- @treturn boolean If the path is mounted, rather than a normal file/folder. | ||||
| -- @throws If the path does not exist. | ||||
| -- @see getDrive | ||||
| -- @since 1.87.0 | ||||
| function fs.isDriveRoot(sPath) | ||||
|     expect(1, sPath, "string") | ||||
| function fs.isDriveRoot(path) | ||||
|     expect(1, path, "string") | ||||
|  | ||||
|     local parent = fs.getDir(path) | ||||
|  | ||||
|     -- Force the root directory to be a mount. | ||||
|     return fs.getDir(sPath) == ".." or fs.getDrive(sPath) ~= fs.getDrive(fs.getDir(sPath)) | ||||
|     if parent == ".." then return true end | ||||
|  | ||||
|     local drive = fs.getDrive(path) | ||||
|     return drive ~= nil and drive ~= fs.getDrive(parent) | ||||
| end | ||||
|   | ||||
| @@ -147,7 +147,7 @@ handleMetatable = { | ||||
|  | ||||
|                     if format == "l" then | ||||
|                         if handle.readLine then res = handle.readLine() end | ||||
|                     elseif format == "L" and handle.readLine then | ||||
|                     elseif format == "L" then | ||||
|                         if handle.readLine then res = handle.readLine(true) end | ||||
|                     elseif format == "a" then | ||||
|                         if handle.readAll then res = handle.readAll() or "" end | ||||
|   | ||||
| @@ -35,7 +35,7 @@ local function getFilename(sUrl) | ||||
|     return sUrl:match("/([^/]+)$") | ||||
| end | ||||
|  | ||||
| local function get(sUrl) | ||||
| local function get(url) | ||||
|     -- Check if the URL is valid | ||||
|     local ok, err = http.checkURL(url) | ||||
|     if not ok then | ||||
| @@ -43,12 +43,12 @@ local function get(sUrl) | ||||
|         return | ||||
|     end | ||||
|  | ||||
|     write("Connecting to " .. sUrl .. "... ") | ||||
|     write("Connecting to " .. url .. "... ") | ||||
|  | ||||
|     local response = http.get(sUrl) | ||||
|     local response, err = http.get(url) | ||||
|     if not response then | ||||
|         print("Failed.") | ||||
|         return nil | ||||
|         printError(err) | ||||
|         return | ||||
|     end | ||||
|  | ||||
|     print("Success.") | ||||
|   | ||||
| @@ -104,7 +104,7 @@ while running do | ||||
|             end | ||||
|         else | ||||
|             printError(results[2]) | ||||
|             require "cc.internal.exception".report(results[2], results[3], chunk_map) | ||||
|             exception.report(results[2], results[3], chunk_map) | ||||
|         end | ||||
|     else | ||||
|         local parser = require "cc.internal.syntax" | ||||
|   | ||||
| @@ -83,6 +83,10 @@ describe("The fs library", function() | ||||
|             expect(fs.isDriveRoot("/rom/startup.lua")):eq(false) | ||||
|             expect(fs.isDriveRoot("/rom/programs/delete.lua")):eq(false) | ||||
|         end) | ||||
|  | ||||
|         it("returns false for missing files", function() | ||||
|             expect(fs.isDriveRoot("does_not_exist")):eq(false) | ||||
|         end) | ||||
|     end) | ||||
|  | ||||
|     describe("fs.list", function() | ||||
| @@ -555,6 +559,22 @@ describe("The fs library", function() | ||||
|         end) | ||||
|     end) | ||||
|  | ||||
|     describe("fs.getDrive", function() | ||||
|         it("returns the drive for the mount roots", function() | ||||
|             expect(fs.getDrive("")):eq("hdd") | ||||
|             expect(fs.getDrive("rom")):eq("rom") | ||||
|         end) | ||||
|  | ||||
|         it("returns the drive for subdirectories", function() | ||||
|             expect(fs.getDrive("rom/startup.lua")):eq("rom") | ||||
|         end) | ||||
|  | ||||
|         it("returns nothing for missing files", function() | ||||
|             -- Peculiar, but we return no values, rather than nil! | ||||
|             expect(table.pack(fs.getDrive("no_such_file"))):same { n = 0 } | ||||
|         end) | ||||
|     end) | ||||
|  | ||||
|     describe("fs.attributes", function() | ||||
|         it("errors on non-existent files", function() | ||||
|             expect.error(fs.attributes, "xuxu_nao_existe"):eq("/xuxu_nao_existe: No such file") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates