Results 1 to 3 of 3

Thread: Create Mountable Disk Image on intel Mac

  1. #1
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Create Mountable Disk Image on intel Mac

    Hi All,

    I m using qt 4.2.2 on my Mac Intel.
    I have a code in which I am creating disk Image by reading the disk sector.This code is working properly on my Power Pc but when I use this Method on my Intel mac then it is giving the message that the disk is not mountable when I double click on the disk Image.

    If any body know whats is the problem with this on my Mac Intel then plz tell me.

    Thanks.
    Last edited by vishal.chauhan; 8th January 2007 at 07:46. Reason: spelling error

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Create Mountable Disk Image on intel Mac

    It could be an issue of the endianess of the processor. PPC and Intel have different endianess so if you do not write your sector byte by byte you will probably end up with different results depending on the platform that you are using.

  3. #3
    Join Date
    Dec 2006
    Posts
    211
    Thanks
    27
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: Create Mountable Disk Image on intel Mac

    Thanks .

    But I donot know how to solve this.
    I m using this code.

    for(Counter = SectorReadStart; Counter < lTotalSectorsInDrive; Counter=Counter+1024)
    {

    if(TotalSectorsForImage>1024)
    SizeToRead=1024*512;
    else
    SizeToRead=TotalSectorsForImage*512;
    memset(pBuff,0x00,1024*512);

    if(ReadDisk(DiskName, Counter, pBuff,SizeToRead ) != SizeToRead)
    {
    unsigned long dw = 0;
    for(dw = 0; dw < 1024; dw++)
    ReadDisk(DiskName, Counter+dw, pBuff+dw*512,512) ;
    }

    TotalSectorsForImage -= 1024;
    fwrite((void*)pBuff,SizeToRead,1,hFileHandle);
    }

    where ReadDisk is

    unsigned int ReadDisk(char *DriveName,unsigned long SectNo,unsigned char *Buffer, unsigned int Size)
    {

    FILE *pFile = NULL;
    int fileDescriptor;
    ssize_t numBytes;

    fileDescriptor = open ( DriveName, O_RDONLY );
    lseek(fileDescriptor, (off_t) SectNo*SECTSIZE, SEEK_SET);

    // copy the file into the buffer.
    numBytes = read( fileDescriptor, Buffer, Size );
    close(fileDescriptor);

    return numBytes;
    }

    TotalSectorsForImage -= 1024;
    fwrite((void*)pBuff,SizeToRead,1,hFileHandle);


    In which I m reading the 1024 sectors at a time and writing them into the file.

Similar Threads

  1. Create pixmap image from string
    By Morea in forum Qt Programming
    Replies: 5
    Last Post: 17th November 2006, 16:38
  2. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36

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
  •  
Qt is a trademark of The Qt Company.