Example #1
0
qint64 qast::get_freespace(){
    QStorageInfo storage = QStorageInfo::root();
    qDebug() << "Read Only:" << storage.isReadOnly();
    qDebug() << "Volume Name:" << storage.name();
    qDebug() << "File System:" << storage.fileSystemType();
    qDebug() << "Total Size:" << storage.bytesTotal()/1048576 << "MB";
    qDebug() << "Available Size:" << storage.bytesAvailable()/1048576 << "MB";
    return storage.bytesAvailable();
}
Example #2
0
VSCHddDevice::VSCHddDevice(QWidget *parent)
    : QDialog(parent)
{
   m_SelectedDisk = 0;
   m_TotalDisks = 0;
   int i = 0;
   s8 DiskTitle[1024];
   ui.setupUi(this);
   QList<QStorageInfo> hdd = QStorageInfo::mountedVolumes();
   QListIterator<QStorageInfo> it(hdd);
   while(it.hasNext())
   {
   	QStorageInfo  disk = it.next();
       if (i >= VSC_SUPPORTED_DISKS)
       {
          break;
       }
       astring strHdd = disk.rootPath().toStdString();
	VDC_DEBUG( "%s strHdd %s \n",__FUNCTION__, strHdd.c_str());
	s64 totalSize = disk.bytesTotal() / (1024 * 1024);
       s64 leftSize = disk.bytesFree()/ (1024 * 1024);
	VDC_DEBUG( "%s Total %lld M Left %lld M \n",__FUNCTION__, totalSize, leftSize);  
	QString strQtHdd = disk.rootPath();
	HddDriveType diskType = HddGetDriveType(strQtHdd);
	VDC_DEBUG( "%s Type %d \n",__FUNCTION__,  diskType);
	if (totalSize/1024 < 16 || leftSize/1024 < 4)
	{
	    continue;
	}
	if (diskType == HddInternalDrive)
	{
	    /* Add to UI */
           m_Disks[i] = new VSCHddOne(false, i, strHdd, totalSize, 
                                     leftSize, this);
           ui.verticalLayout->addWidget(m_Disks[i] );
           if (i == 0)
           {
               m_Disks[i]->diskSetChecked(true);
           }
           m_TotalDisks ++;
           connect(m_Disks[i], SIGNAL(diskSelectedUpdated(int)), this, SLOT(masterDiskSelected(int)));  
           i ++;
	}
   }
Example #3
0
BOOL OAPIServer::ProcessGetSysDisk(s32 len)
{
	if (len == 0)
	{
		return FALSE;
	}
	char *pRecv = new char[len + 1];
	s32 nRetBody = m_pSocket->Recv((void *)pRecv, len);
	oapi::OAPISysDiskListReq req;
	if (nRetBody == len)
	{
		autojsoncxx::ParsingResult result;
		if (!autojsoncxx::from_json_string(pRecv, req, result)) 
		{
			std::cerr << result << '\n';
			delete [] pRecv;
			return FALSE;
		}
	}

	oapi::OAPISysDiskListRsp dataList;
	QList<QStorageInfo> hdd = QStorageInfo::mountedVolumes();
	QListIterator<QStorageInfo> it(hdd);
	while(it.hasNext())
	{
		QStorageInfo  disk = it.next();
		astring strHdd = disk.rootPath().toStdString();
		
		VDC_DEBUG( "%s strHdd %s \n",__FUNCTION__, strHdd.c_str());
		s64 totalSize = disk.bytesTotal() / (1024 * 1024);
		s64 leftSize = disk.bytesFree()/ (1024 * 1024);
		
		VDC_DEBUG( "%s Total %lld M Left %lld M \n",__FUNCTION__, totalSize, leftSize);  
		QString strQtHdd = disk.rootPath();
		HddDriveType diskType = HddGetDriveType(strQtHdd);
		
		VDC_DEBUG( "%s Type %d \n",__FUNCTION__,  diskType);
		
		if (totalSize/1024 < 4 || leftSize/1024 < 2) /* In G */
		{
			continue;
		}
		
		if (diskType == HddInternalDrive 
			|| diskType == HddRemovableDrive || diskType == HddRemoteDrive)
		{
			oapi::OAPIDisk oapiDisk;
			oapiDisk.strId = disk.device().toStdString();
			oapiDisk.strPath = disk.rootPath().toStdString();
			oapiDisk.nTotalSize = disk.bytesTotal();
			oapiDisk.nFreeSize = disk.bytesFree();
			oapiDisk.nStorSize = 0;
			dataList.list.push_back(oapiDisk);
		}
	}

	std::string strJson = autojsoncxx::to_pretty_json_string(dataList);
	s32 nJsonLen = strJson.length();
	if (nJsonLen <= 0)
	{
		return FALSE;
	}
	
	OAPIHeader header;
	header.cmd = htonl(OAPI_CMD_SYS_DISK_LIST_RSP);
	header.length = htonl(nJsonLen + 1);

	m_pSocket->Send((void *)&header, sizeof(header));
	m_pSocket->Send((void *)strJson.c_str(), nJsonLen + 1);

	return TRUE;
}