mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 11:09:21 +01:00
Added creating an archive on desktop/in current directory feature
This commit is contained in:
parent
9eab5d6d65
commit
c67b0cd282
@ -21,8 +21,8 @@ function filesystem.path(path)
|
|||||||
return path:match("^(.+%/).") or ""
|
return path:match("^(.+%/).") or ""
|
||||||
end
|
end
|
||||||
|
|
||||||
function filesystem.name(path, removeSlashes)
|
function filesystem.name(path)
|
||||||
return path:match(removeSlashes and "%/?([^%/]+)%/?$" or "%/?([^%/]+%/?)$")
|
return path:match("%/?([^%/]+%/?)$")
|
||||||
end
|
end
|
||||||
|
|
||||||
function filesystem.extension(path, lower)
|
function filesystem.extension(path, lower)
|
||||||
|
|||||||
@ -2482,7 +2482,7 @@ local function filesystemTreeUpdateFileListRecursively(tree, path, offset)
|
|||||||
|
|
||||||
if tree.showMode == GUI.IO_MODE_BOTH or tree.showMode == GUI.IO_MODE_DIRECTORY then
|
if tree.showMode == GUI.IO_MODE_BOTH or tree.showMode == GUI.IO_MODE_DIRECTORY then
|
||||||
for i = 1, #expandables do
|
for i = 1, #expandables do
|
||||||
tree:addItem(filesystem.name(expandables[i], true), path .. expandables[i], offset, true)
|
tree:addItem(filesystem.name(expandables[i]):sub(1, -2), path .. expandables[i], offset, true)
|
||||||
|
|
||||||
if tree.expandedItems[path .. expandables[i]] then
|
if tree.expandedItems[path .. expandables[i]] then
|
||||||
filesystemTreeUpdateFileListRecursively(tree, path .. expandables[i], offset + 2)
|
filesystemTreeUpdateFileListRecursively(tree, path .. expandables[i], offset + 2)
|
||||||
|
|||||||
@ -483,7 +483,7 @@ function system.icon(x, y, path, textColor, selectionColor)
|
|||||||
icon.path = path
|
icon.path = path
|
||||||
icon.extension = filesystem.extension(icon.path)
|
icon.extension = filesystem.extension(icon.path)
|
||||||
icon.isDirectory = filesystem.isDirectory(icon.path)
|
icon.isDirectory = filesystem.isDirectory(icon.path)
|
||||||
icon.name = filesystem.name(path, true)
|
icon.name = icon.isDirectory and filesystem.name(path):sub(1, -2) or filesystem.name(path)
|
||||||
icon.nameWithoutExtension = filesystem.hideExtension(icon.name)
|
icon.nameWithoutExtension = filesystem.hideExtension(icon.name)
|
||||||
icon.isShortcut = false
|
icon.isShortcut = false
|
||||||
icon.selected = false
|
icon.selected = false
|
||||||
@ -757,12 +757,12 @@ local function iconOnRightClick(icon, e1, e2, e3, e4)
|
|||||||
local container = addBackgroundContainerWithInput("", system.localization.newFolderFromChosen .. " (" .. #selectedIcons .. ")", system.localization.folderName)
|
local container = addBackgroundContainerWithInput("", system.localization.newFolderFromChosen .. " (" .. #selectedIcons .. ")", system.localization.folderName)
|
||||||
|
|
||||||
container.input.onInputFinished = function()
|
container.input.onInputFinished = function()
|
||||||
local path = filesystem.path(selectedIcons[1].path) .. container.input.text
|
local path = filesystem.path(selectedIcons[1].path) .. container.input.text .. "/"
|
||||||
if checkFileToExists(container, path) then
|
if checkFileToExists(container, path) then
|
||||||
filesystem.makeDirectory(path)
|
filesystem.makeDirectory(path)
|
||||||
|
|
||||||
for i = 1, #selectedIcons do
|
for i = 1, #selectedIcons do
|
||||||
filesystem.rename(selectedIcons[i].path, path .. "/" .. selectedIcons[i].name)
|
filesystem.rename(selectedIcons[i].path, path .. selectedIcons[i].name)
|
||||||
end
|
end
|
||||||
|
|
||||||
iconFieldSaveIconPosition(icon.parent.parent, container.input.text, e3, e4)
|
iconFieldSaveIconPosition(icon.parent.parent, container.input.text, e3, e4)
|
||||||
@ -776,13 +776,15 @@ local function iconOnRightClick(icon, e1, e2, e3, e4)
|
|||||||
contextMenu:addSeparator()
|
contextMenu:addSeparator()
|
||||||
end
|
end
|
||||||
|
|
||||||
contextMenu:addItem(system.localization.archive .. (#selectedIcons > 1 and " (" .. #selectedIcons .. ")" or "")).onTouch = function()
|
local subMenu = contextMenu:addSubMenu(system.localization.archive .. (#selectedIcons > 1 and " (" .. #selectedIcons .. ")" or ""))
|
||||||
|
|
||||||
|
local function archive(where)
|
||||||
local itemsToArchive = {}
|
local itemsToArchive = {}
|
||||||
for i = 1, #selectedIcons do
|
for i = 1, #selectedIcons do
|
||||||
table.insert(itemsToArchive, selectedIcons[i].path)
|
table.insert(itemsToArchive, selectedIcons[i].path)
|
||||||
end
|
end
|
||||||
|
|
||||||
local success, reason = require("Compressor").pack(filesystem.path(icon.path) .. "/Archive.pkg", itemsToArchive)
|
local success, reason = require("Compressor").pack(where .. "/Archive.pkg", itemsToArchive)
|
||||||
if not success then
|
if not success then
|
||||||
GUI.alert(reason)
|
GUI.alert(reason)
|
||||||
end
|
end
|
||||||
@ -790,6 +792,14 @@ local function iconOnRightClick(icon, e1, e2, e3, e4)
|
|||||||
computer.pushSignal("system", "updateFileList")
|
computer.pushSignal("system", "updateFileList")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
subMenu:addItem(system.localization.inCurrentDirectory).onTouch = function()
|
||||||
|
archive(filesystem.path(icon.path))
|
||||||
|
end
|
||||||
|
|
||||||
|
subMenu:addItem(system.localization.onDesktop).onTouch = function()
|
||||||
|
archive(paths.user.desktop)
|
||||||
|
end
|
||||||
|
|
||||||
local function cutOrCopy(cut)
|
local function cutOrCopy(cut)
|
||||||
for i = 1, #icon.parent.children do
|
for i = 1, #icon.parent.children do
|
||||||
icon.parent.children[i].cut = nil
|
icon.parent.children[i].cut = nil
|
||||||
@ -817,7 +827,7 @@ local function iconOnRightClick(icon, e1, e2, e3, e4)
|
|||||||
for i = 1, #selectedIcons do
|
for i = 1, #selectedIcons do
|
||||||
if not selectedIcons[i].isShortcut then
|
if not selectedIcons[i].isShortcut then
|
||||||
system.createShortcut(
|
system.createShortcut(
|
||||||
filesystem.path(selectedIcons[i].path) .. "/" .. selectedIcons[i].nameWithoutExtension .. ".lnk",
|
filesystem.path(selectedIcons[i].path) .. selectedIcons[i].nameWithoutExtension .. ".lnk",
|
||||||
selectedIcons[i].path
|
selectedIcons[i].path
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user