file.txt content:
This is a test file.
Command:
output -o file.txt
then it shows the content of the file.. like this:
Title of the File: file.txt
Content:
This is a test file.
Posted 28 May 2014 - 02:48 PM
output -o file.txt
Posted 28 May 2014 - 02:49 PM
Edited by CometWolf, 28 May 2014 - 02:50 PM.
Posted 28 May 2014 - 03:00 PM
function printUsage()
print("Usage: file [(OPTION)] [(File Name)]")
print(" ")
print("-find -- Is an option that finds a file.")
print(" ")
print("-o -- It shows the output of your file content.")
end
-- This program was created by IsaacTBest.
-- This is OpenSource
-- License: GNU/GPLv3 License.
-- Read GNU/GPLv3 License to know more about the laws.
local tArgs = { ... }
if #tArgs < 1 then
printUsage()
end
local sCommand = tArgs[1]
if sCommand == "-find" then
local sPath = shell.resolve( tArgs[2] )
local tFiles = fs.find( sPath )
if #tFiles > 0 then
for n,sFile in ipairs( tFiles ) do
if fs.exists( sFile ) then
print("File Exists!");
else
printUsage();
end
end
else
printError( "File does not exist!" )
end
end
if sCommand == "-o" then
local sPath = shell.resolve( tArgs[2] )
local tFiles = fs.find( sPath )
for n,sFile in ipairs( tFiles ) do
if fs.exists( sFile ) then
print("Title of file: "..sFile)
print("Content:")
print(file.readAll())
else
printError( "File does not exist!" )
end
end
end
Edited by IsaacTBeast, 28 May 2014 - 03:11 PM.
Posted 28 May 2014 - 03:16 PM
Posted 28 May 2014 - 03:19 PM
CometWolf, on 28 May 2014 - 03:16 PM, said:
function printUsage()
print("Usage: file [(OPTION)] [(File Name)]")
print(" ")
print("-find -- Is an option that finds a file.")
print(" ")
print("-o -- It shows the output of your file content.")
end
-- This program was created by IsaacTBest.
-- This program is OpenSource.
-- License: GNU/GPLv3 License.
-- Read GNU/GPLv3 License to know more about the laws.
local tArgs = { ... }
if #tArgs < 1 then
printUsage()
end
local sCommand = tArgs[1]
if sCommand == "-find" then
local sPath = shell.resolve( tArgs[2] )
local tFiles = fs.find( sPath )
if #tFiles > 0 then
for n,sFile in ipairs( tFiles ) do
if fs.exists( sFile ) then
print("File Exists!");
else
printUsage();
end
end
else
printError( "File does not exist!" )
end
end
if sCommand == "-o" then
local sPath = shell.resolve( tArgs[2] )
local tFiles = fs.find( sPath )
if #tFiles > 0 then
for n,sFile in ipairs( tFiles ) do
if fs.exists( sFile ) then
local file = fs.open( sFile ) // I open the file here. I think it doens't work?
print("Title of file: "..sFile)
print("Content:")
print(file.readAll( sFile ))
file.close()
else
printError( "File does not exist!" )
end
end
end
end
Edited by IsaacTBeast, 28 May 2014 - 03:19 PM.
Posted 28 May 2014 - 03:35 PM
local file = fs.open(fileName,mode) print(file.readAll()) file.close()
Posted 28 May 2014 - 03:36 PM
0 members, 1 guests, 0 anonymous users