Fs (API), what is that?
#1
Posted 29 November 2013 - 05:30 PM
I've seen it in a couple Programs out there, but I don't really understand it - I saw the wiki, but nothing there really helped me, I'm just looking for a quick and easy explanation, and, if possible, some examples.
Thanks.
#2
Posted 29 November 2013 - 06:15 PM
#3
Posted 29 November 2013 - 06:26 PM
#4
Posted 29 November 2013 - 06:30 PM
#5
Posted 29 November 2013 - 06:38 PM
#6
Posted 29 November 2013 - 09:24 PM
Edited by Strite, 29 November 2013 - 09:24 PM.
#7
Posted 29 November 2013 - 09:38 PM
#8
Posted 29 November 2013 - 09:45 PM
EDIT: dat rhyme.
Edited by Strite, 29 November 2013 - 09:45 PM.
#9
Posted 29 November 2013 - 10:30 PM
Strite, on 29 November 2013 - 09:45 PM, said:
EDIT: dat rhyme.
A program is a file that can be run. Files and directories (or folders) are part of a file structure. Directories CONTAIN files.
Files are where data is stored. Pictures, images, programs, plain text, even applications are types of files. The FS API is an API used for editing or reading files in their plaintext or binary forms, or also for creating directories, and moving/deleting/copying files/directories.
TL;DR: Go back and take a minute of your time to read what I said.
#10
Posted 29 November 2013 - 11:55 PM
Strite, on 29 November 2013 - 09:45 PM, said:
EDIT: dat rhyme.
#11
Posted 30 November 2013 - 12:30 AM
#12
Posted 30 November 2013 - 12:55 AM
But an example i can give is a password lock
repeat if fs.exists("password") then fileHandle = fs.open("password","r") -- open file in read mode local pass = fileHandle.readAll() -- read everything in the file fileHandle.close() -- make sure to close else write("Enter new password: ") local pass = read("*") fileHandle = fs.open("password","w") -- open file in write mode fileHandle.write(pass) -- store password in the file fileHandle.close() -- again close the file end term.clear() term.setCursorPos(1,1) write("Enter Your Password: ") input = read("*") until input == pass
Edit: Basically if a password file doesn't exist yet then it will create the file and write the password to it otherwise it will read from the password file and then store it in the variable called pass and then compare later on
Edited by jay5476, 30 November 2013 - 12:57 AM.
#13
Posted 30 November 2013 - 01:03 AM
But still, thank you guys, this whole topic is much more clear now, at least know I know the very basics, you really helped me!
See ya' all later!
Edited by Strite, 30 November 2013 - 01:04 AM.
#14
Posted 30 November 2013 - 01:41 AM
#15
Posted 30 November 2013 - 02:35 AM
Strite, on 29 November 2013 - 06:30 PM, said:
They're not. When you use the FS API to open a file and write data into it, it's creating a real file on the server and writing data into that. The whole MineCraft server can be shut down and restarted and your file will stay there, ready to read from when you want it. On the other hand, the contents of your CC computer's "RAM" gets cleared as soon as the chunk they're in unloads (same as what happens to the RAM of your real computer if you turn THAT off).
#16
Posted 17 December 2013 - 08:58 PM
Here's the code: pastebin.com/4L8tLppc
What am I doing wrong?
#17
Posted 17 December 2013 - 11:06 PM
#18
Posted 18 December 2013 - 07:30 AM
--start level 1 repeat --start level 2 if x == 1 then --start level 3 print("asdf") --end level 3 end --end level 2 until y == 1 --end level 1
You can fix your code by declaring pass before the repeat loop with say, local pass = "", then inside the if statement, change that to pass = file.readAll()
This is an example of block scope in programming. Read about it in http://en.wikipedia....mputer_science)
Edited by Patric20878, 18 December 2013 - 07:45 AM.
#19
Posted 18 December 2013 - 09:35 AM
While you are at it, I would encrypt or hash the password on disk. I use GravityScore's SHA256 Algorithm to hash passwords on disk, and then I hash the input as well in awsmazingOS.
Edited by awsmazinggenius, 18 December 2013 - 09:36 AM.
#20
Posted 18 December 2013 - 02:07 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users