Jump to content




HDD Api


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

#1 FoxData

  • Members
  • 159 posts

Posted 19 June 2016 - 09:52 PM

Hi everyone. This API will allow you to perform certain actions on disk drives.

Here are some code snippets:

Drive.ShowSpace - Shows the current space of the HDD returns nil when it has no space
Drive.Wipe - Wipes the HDD
Drive.Park - Parks the HDD heads
Drive.Encrypt - Encrypts the HDD
Drive.Space - A var that returns the space of the drive to if statements
Drives.GetExtDrives - Retrieves Info about external fdd drives
- Here's some proper code
While true do
Print(Drive.ShowSpace)
if Drive.Space = 0.0 then print ("Out of Space")
end


So what do you think of this API? Will it be added to CC? CraftOS 2.0's Drive API?

#2 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 19 June 2016 - 10:30 PM

 FoxData, on 19 June 2016 - 09:52 PM, said:

Hi everyone. This API will allow you to perform certain actions on disk drives.

Here are some code snippets:

Drive.ShowSpace - Shows the current space of the HDD returns nil when it has no space
Drive.Wipe - Wipes the HDD
Drive.Park - Parks the HDD heads
Drive.Encrypt - Encrypts the HDD
Drive.Space - A var that returns the space of the drive to if statements
Drives.GetExtDrives - Retrieves Info about external fdd drives
- Here's some proper code
While true do
Print(Drive.ShowSpace)
if Drive.Space = 0.0 then print ("Out of Space")
end


So what do you think of this API? Will it be added to CC? CraftOS 2.0's Drive API?

Everything (okay, not the encryption) can be done with either a normal fs call, or a small amount of lines (using the fs API)

I don't see why this would be needed at all

//EDIT:
Here's an example for "Wipe"

Not tested and written on my phone, but I think you can get the idea
function wipe(start) 
  start = start or "/" 
  for k,v in pairs(fs.list(start)) do
    if (fs.isDir(fs.combine(start,v)) and not (start == "/" and v== "rom")) then
      wipe(fs.combine(start,v))
    else
      if(not (start == "/" and v == "rom") ) then
        fs.delete(fs.combine(start,v)
      end
    end
  end
end

Edited by H4X0RZ, 19 June 2016 - 10:38 PM.


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 20 June 2016 - 12:27 AM

I don't think anybody who had to use it actually misses park. ;)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users