Results 1 to 4 of 4

Thread: detecting disks

  1. #1
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    1

    Default detecting disks

    hi all,

    i am working on objective c. i want to detect programmatically that how many disks are connected to mac (mounted or not) and how can identify the disk( ie. whether it is hard disk, USB or anything else). if anybody has idea about this please share.


    thanks in advance

    with regards
    Nishad.

  2. #2
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: detecting disks

    Quote Originally Posted by nishad_kumar View Post
    hi all,

    i am working on objective c. i want to detect programmatically that how many disks are connected to mac (mounted or not) and how can identify the disk( ie. whether it is hard disk, USB or anything else). if anybody has idea about this please share.


    thanks in advance

    with regards
    Nishad.
    I suppose you must only Read /Volumes dir on this dir is all mounted device...





    Qt Code:
    1. void Setting_Gui::WebdavSetup()
    2. {
    3. label_webdav->setText(tr("Your OS Not Support Webdav"));
    4. QStringList diskremote;
    5. QString disksetting = Global_Config(APPLICATION_SETTING,"webdav_root");
    6. #if defined Q_WS_WIN
    7. /* http://ciz.ch/service/98,1142862047/de/ netdrive webdrive */
    8. label_webdav->setText(tr("Window XP/2000 OS: Webdav Root (Radice)"));
    9. QString alfa ="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
    10. diskremote = alfa.split(",");
    11. webdav_root->clear();
    12. int loop= 0 - 1;
    13. int activeselected;
    14. QStringListIterator o(diskremote);
    15. while (o.hasNext()) {
    16. loop++;
    17. QString disker = o.next();
    18. QString diskeree = disker.append(":/");
    19. webdav_root->addItem(diskeree);
    20. if (disksetting == diskeree) {
    21. activeselected = loop;
    22. }
    23. }
    24. webdav_root->setEditable(false);
    25. webdav_root->setCurrentIndex(activeselected);
    26. #endif
    27. #if defined Q_WS_MAC
    28. /* apple + K */
    29. label_webdav->setText(tr("Mac OS: Mount Disk Webdav Root"));
    30. QString listdiron ="/Volumes/";
    31. webdav_root->addItem(disksetting);
    32. /* webdav_root->addItem(listdiron);*/
    33. QDir dir(listdiron);
    34. if (dir.exists()) {
    35. const QFileInfoList list = dir.entryInfoList();
    36. for (int i = 0; i < list.size(); i++)
    37. {
    38. fi = list.at(i);
    39. if (fi.isDir() && fi.fileName() != "." && fi.fileName() != "..") {
    40. QString disker = fi.absoluteFilePath();
    41. QString diskeree = disker.append("/");
    42. webdav_root->addItem(diskeree);
    43. }
    44. }
    45. }
    46. webdav_root->setEditable(false);
    47. #endif
    48.  
    49. #if defined Q_WS_X11
    50. /* http://www.webdav.org/cadaver/ */
    51. label_webdav->setText(tr("Linux OS: Mount Disk Webdav Root"));
    52. QString listdiron ="/mnt/";
    53. webdav_root->setEditable(true);
    54. webdav_root->addItem(disksetting);
    55. webdav_root->addItem(listdiron);
    56. #endif
    57.  
    58. }
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to patrik08 for this useful post:

    nishad_kumar (6th September 2007)

  4. #3
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    1

    Default Re: detecting disks

    thanks for the replay.

    with regards
    Nishad

  5. #4
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    1

    Default Re: detecting disks

    hi,

    thanks all

    i got the drives mounted on mac programmatically by reading /volumes. but actually i need to find the size of each drive. can anybody help me to find programmatically size of drive ?.

    with regards
    Nishad.

Similar Threads

  1. Detecting user inaction
    By jrideout in forum Qt Programming
    Replies: 5
    Last Post: 10th December 2010, 07:37
  2. Detecting low memory
    By steg90 in forum General Programming
    Replies: 3
    Last Post: 11th June 2007, 18:54
  3. Detecting the last empty line in a file
    By Ti_Thom in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2006, 05:14
  4. Detecting end of dialog move
    By darryl in forum Qt Programming
    Replies: 20
    Last Post: 12th September 2006, 14:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.