diff --git a/sys/apis/util.lua b/sys/apis/util.lua index 771bcbb..2a3fb64 100644 --- a/sys/apis/util.lua +++ b/sys/apis/util.lua @@ -414,6 +414,16 @@ end function Util.writeFile(fname, data) if not fname or not data then error('Util.writeFile: invalid parameters', 2) end + + if fs.exists(fname) then + local diff = #data - fs.getSize(fname) + if diff > 0 then + if fs.getFreeSpace(fs.getDir(fname)) < diff then + error('Insufficient disk space for ' .. fname) + end + end + end + local file = io.open(fname, "w") if not file then error('Unable to open ' .. fname, 2) diff --git a/sys/apps/cedit.lua b/sys/apps/cedit.lua index 8032688..5abcee0 100644 --- a/sys/apps/cedit.lua +++ b/sys/apps/cedit.lua @@ -13,6 +13,7 @@ if not _G.http.websocket then end if not _G.cloud_catcher then + print('Visit https://cloud-catcher.squiddev.cc') print('Paste key: ') local key = read() if #key == 0 then diff --git a/sys/apps/cshell.lua b/sys/apps/cshell.lua index 7bc6af6..91b1eab 100644 --- a/sys/apps/cshell.lua +++ b/sys/apps/cshell.lua @@ -6,6 +6,7 @@ if not _G.http.websocket then end if not _G.cloud_catcher then + print('Visit https://cloud-catcher.squiddev.cc') print('Paste key: ') local key = read() if #key == 0 then diff --git a/sys/extensions/2.vfs.lua b/sys/extensions/2.vfs.lua index 3558c60..d80474c 100644 --- a/sys/extensions/2.vfs.lua +++ b/sys/extensions/2.vfs.lua @@ -113,6 +113,7 @@ local function splitpath(path) end local function getNode(dir) + if not dir then error('Invalid directory', 2) end local cd = fs.combine(dir, '') local parts = splitpath(cd) local node = fs.nodes @@ -176,6 +177,8 @@ function fs.listEx(dir) end function fs.copy(s, t) + if not s then error('copy: bad argument #1') end + if not t then error('copy: bad argument #2') end local sp = getNode(s) local tp = getNode(t) if sp == tp and sp.fs.copy then diff --git a/sys/help/CloudCatcher b/sys/help/CloudCatcher new file mode 100644 index 0000000..e50dd86 --- /dev/null +++ b/sys/help/CloudCatcher @@ -0,0 +1,5 @@ +Cloud Catcher is a web terminal for ComputerCraft, allowing you to interact with any in-game computer in the browser, as well as edit files remotely! + +To get started, visit https://cloud-catcher.squiddev.cc/cloud.lua for a session key. + +Within Files, press 'c' to edit a file using Cloud Catcher.