Logo Search packages:      
Sourcecode: k9copy version File versions  Download package

int K3bDevice::Device::isEmpty (  )  const

checks if disk is empty, returns K3bDevice::State

Definition at line 557 of file k3bdevice.cpp.

References close(), isOpen(), open(), readDiscInfo(), and testUnitReady().

{
  // if the device is already opened we do not close it
  // to allow fast multible method calls in a row
  bool needToClose = !isOpen();

  int ret = STATE_UNKNOWN;
  if( !open() )
    return STATE_UNKNOWN;

  if( !testUnitReady() )
    return STATE_NO_MEDIA;

  unsigned char* data = 0;
  int dataLen = 0;

  if( readDiscInfo( &data, dataLen ) ) {
    disc_info_t* inf = (disc_info_t*)data;
    switch( inf->status ) {
    case 0:
      ret = STATE_EMPTY;
      break;
    case 1:
      ret = STATE_INCOMPLETE;
      break;
    case 2:
      ret = STATE_COMPLETE;
      break;
    default:
      ret = STATE_UNKNOWN;
      break;
    }

    delete [] data;
  }

  if( needToClose )
    close();

  return ret;
}


Generated by  Doxygen 1.6.0   Back to index