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

How to get if a disk is a Pocket Computer.

Started by Lamdax, 01 November 2014 - 10:35 AM
Lamdax #1
Posted 01 November 2014 - 11:35 AM
Hi,

I'm attempting to make a Pocket Computer program (which involves copying data from a computer). However, there is no disk API function to check if the disk is a Pocket Computer. For example, disk.hasData() returns true with either a floppy disk OR a Pocket Computer.

My question:
Is it possible to tell if a disk is either a Pocket Computer or a floppy disk? If so, how do I do it?

Thank you.
metron80 #2
Posted 04 November 2014 - 03:40 AM
From what I saw, there is no way to check if it is a Pocket Computer. You can see if it is a floppy disk with this command:

disk.hasData(string side)
That returns a boolean saying whether or not it is a floppy disk. More infomation: http://computercraft.info/wiki/Disk_(API)

Hope I helped! ^_^/>
Dragon53535 #3
Posted 04 November 2014 - 04:00 AM
More than likely if you can find a file that only exists on a pocket computer, then you can test to see if that file exists.
KingofGamesYami #4
Posted 04 November 2014 - 04:07 AM
Eg: https://github.com/alekso56/ComputercraftLua/blob/master/rom/programs/pocket/falling
oeed #5
Posted 04 November 2014 - 04:11 AM
I'm not entirely sure if this will work and it's won't work if the config is changed, but you could do something like this:


local diskType = 'music'
if disk.hasData(side) then
  local mountPath = disk.getMountPath(side)
  if fs.getSize(mountPath) + fs.getFreeSpace(mountPath) > x then
    diskType = 'pocket'
  else
    diskType = 'data'
  end
end

I'm not sure what 'x' is, but I'm sure you could find it.