diff --git a/miniOS/LICENCE b/miniOS/LICENCE new file mode 100644 index 0000000..12b850e --- /dev/null +++ b/miniOS/LICENCE @@ -0,0 +1,3 @@ +miniOS is written by Skye M. +The code is partially based on code from the OpenComputers mod under the MIT licence (see LICENCE.mit). +Modifications and extensions to the code, and new code is under the 2-clause BSD licence (see LICENCE.bsd). diff --git a/miniOS/LICENCE.bsd b/miniOS/LICENCE.bsd new file mode 100644 index 0000000..3a3c44b --- /dev/null +++ b/miniOS/LICENCE.bsd @@ -0,0 +1,25 @@ +BSD 2-Clause License + +Copyright (c) 2020, Skye M. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/miniOS/LICENCE.mit b/miniOS/LICENCE.mit new file mode 100644 index 0000000..9e8ad4f --- /dev/null +++ b/miniOS/LICENCE.mit @@ -0,0 +1,19 @@ +Copyright (c) 2013-2015 Florian "Sangar" Nücke + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/miniOS/command.lua b/miniOS/command.lua index 06203dd..1d95cdd 100644 --- a/miniOS/command.lua +++ b/miniOS/command.lua @@ -55,7 +55,7 @@ local function listdrives() end end -local function lables() +local function labels() for letter, address in fs.drive.list() do print(letter, component.invoke(address, "getLabel") or "") end @@ -205,7 +205,8 @@ local function runline(line) if command == "disks" then listdrives() return true end if command == "discs" then listdrives() return true end if command == "drives" then listdrives() return true end - if command == "labels" then lables() return true end + if command == "labels" then labels() return true end + if command == "scndrv" then filesystem.drive.scan() return true end if command == "label" then if parts[2] then label(parts) return true else printErr("Invalid Parameters") return false end end if command == "type" then outputFile(fixPath(parts[2])) return true end if command == "more" then outputFile(fixPath(parts[2]), true) return true end @@ -228,6 +229,7 @@ cmds --- Lists the commands. intro -- Outputs the introduction message. drives - Lists the drives and their addresses. labels - Lists the drives and their labels. +scndrv - Updates the drive list. label -- Sets the label of a drive. echo --- Outputs its arguments. type --- Like echo, but outputs a file. diff --git a/miniOS/miniOS.lua b/miniOS/miniOS.lua index c4ec17a..10b0098 100644 --- a/miniOS/miniOS.lua +++ b/miniOS/miniOS.lua @@ -1,7 +1,7 @@ _G._OSNAME = "miniOS classic" -_G._OSVER = "0.6.2-pre.1" +_G._OSVER = "0.6.2" _G._OSVERSION = _OSNAME .. " " .. _OSVER -_G._OSCREDIT = "miniOS classic by Skye, based off of OpenOS code from OpenComputers.\nminiOS code is under BSD 2-clause license, OpenOS code is under the MIT license." +_G._OSCREDIT = "miniOS classic by Skye, based off of OpenOS code from OpenComputers.\nminiOS code is under BSD 2-clause licence, OpenOS code is under the MIT licence." --component code function component_code() @@ -432,14 +432,14 @@ function fs_code() fs.drive._map = {} --converts a drive letter into a proxy function fs.drive.letterToProxy(letter) - return fs.drive._map[letter] + return fs.drive._map[letter] end --finds the proxy associated with the letter function fs.drive.proxyToLetter(proxy) for l,p in pairs(fs.drive._map) do - if p == proxy then return l end - end - return nil + if p == proxy then return l end + end + return nil end --maps a proxy to a letter function fs.drive.mapProxy(letter, proxy) @@ -457,8 +457,9 @@ function fs_code() return nil end function fs.drive.mapAddress(letter, address) - --print("mapAddress") - fs.drive._map[letter] = fs.proxy(address) + --print("mapAddress") + if address == nil then fs.drive._map[letter] = nil + else fs.drive._map[letter] = fs.proxy(address) end end function fs.drive.autoMap(address) --returns the letter if mapped OR already mapped, false if not. --print("autoMap") @@ -517,6 +518,20 @@ function fs_code() return drive, path end function fs.drive.getcurrent() return fs.drive._current end + function fs.drive.scan() + local to_remove = {} + for letter,proxy in pairs(fs.drive._map) do + if component.type(proxy.address) == nil then + to_remove[#to_remove + 1] = letter + end + end + for _,l in ipairs(to_remove) do + fs.drive._map[l] = nil + end + for address, componentType in component.list() do + if componentType == "filesystem" then filesystem.drive.autoMap(address) end + end + end function fs.invoke(method, ...) return fs.drive._map[fs.drive._current][method](...) end function fs.proxy(filter) checkArg(1, filter, "string") @@ -1296,10 +1311,7 @@ print(_OSCREDIT .. "\n") --clean up libs event_code, component_code, text_code, fs_code, terminal_code, keyboard_code = nil, nil, nil, nil, nil, nil ---map the drives -for address, componentType in component.list() do - if componentType == "filesystem" then filesystem.drive.autoMap(address) end -end +filesystem.drive.scan() miniOS = {} local function interrupt(data) @@ -1412,8 +1424,5 @@ while true do if not miniOS.cmdBat then print() end fs.drive.setcurrent(fallback_drive) local new = false; - --print(new) if not shellrun("command.lua", (not new and "-c") or nil) then new = true; printErr("Will restart command interpreter..."); kernelError(); end - --print("uh") - --os.sleep(1) end diff --git a/miniOS/version.txt b/miniOS/version.txt index a57faf9..c247e1b 100644 --- a/miniOS/version.txt +++ b/miniOS/version.txt @@ -1,3 +1,3 @@ miniOS classic -0.6.2-pre.1 +0.6.2 Alpha diff --git a/miniOSNT b/miniOSNT index f489494..f2bb63f 160000 --- a/miniOSNT +++ b/miniOSNT @@ -1 +1 @@ -Subproject commit f48949404336f8b7c1a8ff376763234657b173a8 +Subproject commit f2bb63f8d4993d876568742f701dc9ff99f9749c