OctOS: Add mkdir, rmdir, and cpdir commands
Documented in `commands.md`. Allow manipulation of directories.
This commit is contained in:
parent
b84a250c25
commit
cfc1bb4e79
@ -16,5 +16,14 @@ Create new file.
|
||||
#### `rm [path]`
|
||||
Remove file.
|
||||
|
||||
#### `cp [old path] [new path]`
|
||||
Make a copy of a file.
|
||||
#### `cp [old path] [copy path]`
|
||||
Make a copy of a file.
|
||||
|
||||
#### `mkdir [path]`
|
||||
Create new directory.
|
||||
|
||||
#### `rmdir [path]`
|
||||
Remove directory.
|
||||
|
||||
#### `cpdir [old path] [copy path]`
|
||||
Make a copy of a directory.
|
4
octos/bin/cpdir
Normal file
4
octos/bin/cpdir
Normal file
@ -0,0 +1,4 @@
|
||||
name = cpdir
|
||||
description = Copy directory
|
||||
params = [original path] [copy path]
|
||||
exec = os/exec/cpdir.lua
|
4
octos/bin/mkdir
Normal file
4
octos/bin/mkdir
Normal file
@ -0,0 +1,4 @@
|
||||
name = mkdir
|
||||
description = Create directory
|
||||
params = [path]
|
||||
exec = os/exec/mkdir.lua
|
4
octos/bin/rmdir
Normal file
4
octos/bin/rmdir
Normal file
@ -0,0 +1,4 @@
|
||||
name = rmdir
|
||||
description = Remove directory
|
||||
params = [path]
|
||||
exec = os/exec/rmdir.lua
|
21
octos/exec/cpdir.lua
Normal file
21
octos/exec/cpdir.lua
Normal file
@ -0,0 +1,21 @@
|
||||
local path = ...
|
||||
local old = path[1]
|
||||
local new = path[2]
|
||||
|
||||
if old and new then
|
||||
if fs.exists(old) then
|
||||
if not fs.exists(new) then
|
||||
if fs.cpdir(old, new) then
|
||||
print("Copied "..old.." to "..new)
|
||||
else
|
||||
print(old.." is a file")
|
||||
end
|
||||
else
|
||||
print(new.." already exists")
|
||||
end
|
||||
else
|
||||
print(old.." does not exist")
|
||||
end
|
||||
else
|
||||
print("Must specify original and new path (see help cpdir)")
|
||||
end
|
16
octos/exec/mkdir.lua
Normal file
16
octos/exec/mkdir.lua
Normal file
@ -0,0 +1,16 @@
|
||||
local path = ...
|
||||
path = path[1]
|
||||
|
||||
if path then
|
||||
if not fs.exists(path) then
|
||||
if fs.mkdir(path) then
|
||||
print("Created directory "..path)
|
||||
else
|
||||
print("Could not create directory "..path)
|
||||
end
|
||||
else
|
||||
print(path.." already exists")
|
||||
end
|
||||
else
|
||||
print("Must specify path (see help mkdir)")
|
||||
end
|
16
octos/exec/rmdir.lua
Normal file
16
octos/exec/rmdir.lua
Normal file
@ -0,0 +1,16 @@
|
||||
local path = ...
|
||||
path = path[1]
|
||||
|
||||
if path then
|
||||
if fs.exists(path) then
|
||||
if fs.rmdir(path) then
|
||||
print("Removed directory "..path)
|
||||
else
|
||||
print(path.." is not a directory")
|
||||
end
|
||||
else
|
||||
print(path.." does not exist")
|
||||
end
|
||||
else
|
||||
print("Must specify path (see help rmdir)")
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user