This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
FoxData's profile picture

HDD Api

Started by FoxData, 19 June 2016 - 08:52 PM
FoxData #1
Posted 19 June 2016 - 10: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?
H4X0RZ #2
Posted 19 June 2016 - 11:30 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?

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 on 19 June 2016 - 09:38 PM
Bomb Bloke #3
Posted 20 June 2016 - 01:27 AM
I don't think anybody who had to use it actually misses park. ;)/>