Jump to content




fs.new


  • You cannot reply to this topic
5 replies to this topic

#1 Rougeminner

  • Members
  • 151 posts

Posted 20 September 2014 - 05:21 PM

I am trying to rewrite the fs api for my operating system but i have been having problems with fs.open(). my code is obviously flawed because every time i use it the OS drops everything but itself. if you try to use any commands it says file not found. here is my code
local error1 = "fs error 1: This File is locked"
local error2 = "fs error 2: This File is read only"
local oldfs = {}
for k,v in pairs( fs ) do
oldfs[k] = v
end
function fs.move( fpath , tpath)
if fpath:sub(1,1) == ',' then
print("fs error 1: This File is locked")
else
oldfs.move(fpath,tpath)
end
end
function fs.opened( path,mode)
if path:sub(1,1) == ',' then
print(error2)
oldfs.open(path,'r')
else oldfs.open(path,mode)
end
end
function fs.delete(path)
if path:sub(1,1)==',' then
error(error1)
else
oldfs.delete(path)
end
end

can i get some help with this please.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 20 September 2014 - 06:04 PM

Don't change the name of the function and expect everything to work properly still. Change your replacement function name from opened to open.

#3 Anavrins

  • Members
  • 775 posts

Posted 20 September 2014 - 06:15 PM

Fixed indentation for readability...
Spoiler
You have renamed fs.open to fs.opened, which might be your problem.

Edited by Anavrins, 20 September 2014 - 06:16 PM.


#4 Rougeminner

  • Members
  • 151 posts

Posted 24 September 2014 - 02:26 AM

i renamed it to see if it would fix my problem

didn't work to well forgot to replace it

EDIT: even with it replaced to fs.open it did not work


@lyqyd I didn't think it was going to work immediately. i was so doubtful that is was going to work i stopped working on it

Edited by Rougeminner, 24 September 2014 - 02:32 AM.


#5 natedogith1

  • Members
  • 110 posts

Posted 25 September 2014 - 02:52 AM

Remember when you're calling old functions to do something with their value:
function fs.open(path, mode)
  oldfs.open(path, mode) --this will cause issues
end

function fs.open(path, mod)
  return oldfs.open(path, mode) --remembering to return the stuff
end
Also, you say the OS drops everything but itself, what do you mean by this?

#6 Rougeminner

  • Members
  • 151 posts

Posted 27 September 2014 - 04:30 AM

it says "file doesn't exist" not found something along those lines

edit: THANK YOU NATE THAT FIXED ALL MY PROBLEMS WITH FS.OPEN. to bad there is not a emoji icon for smacking myself in the forehead :)

Edited by Rougeminner, 27 September 2014 - 04:30 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users