OctOS: Add mkdir, rmdir, and cpdir commands
Documented in `commands.md`. Allow manipulation of directories.master
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.
|
|
@ -0,0 +1,4 @@
|
|||
name = cpdir
|
||||
description = Copy directory
|
||||
params = [original path] [copy path]
|
||||
exec = os/exec/cpdir.lua
|
|
@ -0,0 +1,4 @@
|
|||
name = mkdir
|
||||
description = Create directory
|
||||
params = [path]
|
||||
exec = os/exec/mkdir.lua
|
|
@ -0,0 +1,4 @@
|
|||
name = rmdir
|
||||
description = Remove directory
|
||||
params = [path]
|
||||
exec = os/exec/rmdir.lua
|
|
@ -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
|
|
@ -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
|
|
@ -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…
Reference in New Issue