Jump to content




Getting Every File for "OS"


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

#1 PixelFox

  • Members
  • 106 posts

Posted 13 April 2015 - 08:33 PM

My "Operating System" (It can't really be called that...It's more that the file explorer in windows or the finder in mac)
I want to find every single file BUT the system files, .menu and .gui, and save them in a variable or something that I can manipulate, so I can show them in the GUI or Graphical User Interface. I really can't find out how, is there some kind of simple something to do that with, and also, will it show APIs also?
I want them to be able to see the APIs. But I'll make them a different Icon.

#2 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 13 April 2015 - 08:39 PM

Are you trying to build a desktop? I don't quite understand your question, could you please clarify?

#3 PixelFox

  • Members
  • 106 posts

Posted 13 April 2015 - 08:43 PM

View PostCreator, on 13 April 2015 - 08:39 PM, said:

Are you trying to build a desktop? I don't quite understand your question, could you please clarify?
Yes, I am. I am wanted every file name except for the startup file, the .gui file and the .menu file. I want the computer to find every file but them, and then put them in variables or something.

Edited by Lightning, 13 April 2015 - 08:44 PM.


#4 valithor

  • Members
  • 1,053 posts

Posted 13 April 2015 - 08:47 PM

Your best bet is to use a table.

If i remember correctly fs.list returns a table of all the files in a given dirrectory. So using this you could use a loop that will loop through all of the files check if they are a dirrectory, and if they are then loop through all the files in that dirrectory and so on.

This will not however get the apis. The easiest way I can think to get the apis would be to do something similar to do this
for k,v in pairs(_G) do 
  if type(v) == "table" then
    -- its most likely a api so do something with it
  end
end


#5 PixelFox

  • Members
  • 106 posts

Posted 13 April 2015 - 08:48 PM

View Postvalithor, on 13 April 2015 - 08:47 PM, said:

Your best bet is to use a table.

If i remember correctly fs.list returns a table of all the files in a given dirrectory. So using this you could use a loop that will loop through all of the files check if they are a dirrectory, and if they are then loop through all the files in that dirrectory and so on.

This will not however get the apis. The easiest way I can think to get the apis would be to do something similar to do this
for k,v in pairs(_G) do
  if type(v) == "table" then
	-- its most likely a api so do something with it
  end
end
Ah, Thanks, but uh...I don't know how I'd do that...I'm kinda a noob.
I know some fs commands...I'll look up the the API later, and thanks with the APIs too.
Oh also, I'm trying to overright a file, and fs.copy returns "testfile:4: File Exists" is there a way to stop that?

Edited by Lightning, 13 April 2015 - 08:53 PM.


#6 valithor

  • Members
  • 1,053 posts

Posted 13 April 2015 - 08:54 PM

View PostLightning, on 13 April 2015 - 08:48 PM, said:

-snip

You can check if the file exists before trying to copy to the name.

if not fs.exists("testfile") then
  fs.copy("hi","testfile")
end

Edited by valithor, 13 April 2015 - 08:54 PM.


#7 PixelFox

  • Members
  • 106 posts

Posted 13 April 2015 - 09:00 PM

View Postvalithor, on 13 April 2015 - 08:54 PM, said:

View PostLightning, on 13 April 2015 - 08:48 PM, said:

-snip

You can check if the file exists before trying to copy to the name.

if not fs.exists("testfile") then
  fs.copy("hi","testfile")
end
Thanks, but I'm trying to overwrite them.

Edited by Lightning, 13 April 2015 - 09:01 PM.


#8 valithor

  • Members
  • 1,053 posts

Posted 13 April 2015 - 09:14 PM

View PostLightning, on 13 April 2015 - 09:00 PM, said:

View Postvalithor, on 13 April 2015 - 08:54 PM, said:

View PostLightning, on 13 April 2015 - 08:48 PM, said:

-snip

You can check if the file exists before trying to copy to the name.

if not fs.exists("testfile") then
  fs.copy("hi","testfile")
end
Thanks, but I'm trying to overwrite them.

Then you will need to delete the file first.

#9 PixelFox

  • Members
  • 106 posts

Posted 13 April 2015 - 09:17 PM

View Postvalithor, on 13 April 2015 - 09:14 PM, said:

View PostLightning, on 13 April 2015 - 09:00 PM, said:

View Postvalithor, on 13 April 2015 - 08:54 PM, said:

View PostLightning, on 13 April 2015 - 08:48 PM, said:

-snip

You can check if the file exists before trying to copy to the name.

if not fs.exists("testfile") then
  fs.copy("hi","testfile")
end
Thanks, but I'm trying to overwrite them.

Then you will need to delete the file first.
Ok, thanks!

#10 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 14 April 2015 - 11:53 PM

If you want to find every single file on the computer you'd need to use a recursive loop
Example






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users