Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > write aC++ program that would read from a CD and display information

Reply
Thread Tools

write aC++ program that would read from a CD and display information

 
 
munif
Guest
Posts: n/a
 
      12-22-2004
i wnat write a C++ program that would read from a CD and display
information about files and folders in the given CD

In simple words you would be performing a simple (ls -l)[Linux] or (DIR
/S)[DOS] on the CD.

LOOk at this code


/*
CopyRight 2004 by Basit Qureshi

The following code illustrates how to open an iso file and read
its contents.

Notice most numbers stored in the CD are in Big_Endian or
Little_Endian format. For instance if a number is stored in
8 bytes long memory this means the first 4 bytes represent
the same number in Little_endian format and the other 4 bytes
respresent the same number in big_endian format.
*/

#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>

#define SECTOR_SIZE 2048
ifstream fin;
unsigned char buf[SECTOR_SIZE];

unsigned char PTAddress[4];
main()
{
fin.open("test2.iso");
//goto locations 16 * sizeof SECTOR to read the PVD
fin.seekg(16*sizeof(buf));
//read 2048 bytes in buffer
fin.read (buf,204;
PTAddress[0]= buf[140]; // first bit
PTAddress[1]= buf[141]; //second bit
PTAddress[2]= buf[142]; // thirdbit
PTAddress[3]= buf[143]; //fourth bit

//convert the above binary number to integer!! notice this is 4 bytes
long
// address = PTAddress[3] * 2^24 + PTAddress[2] * 2^16 +
PTAddress[1] * 2^8 + PTAddress[0] * 2^0;
double address = PTAddress[3] * 16777216 + PTAddress[2] * 65536 +
PTAddress[1] * 256 + PTAddress[0] * 1;

//goto location of the path table
fin.seekg(address*sizeof(buf));
//read the sector that contains the path table.
fin.read(buf,204;
//read the description of the path table. We are concered with the
location of the
//first directory so...goto that location...!

address = buf[5] * 16777216 + buf[4] * 65536 + buf[3] * 256 + buf[2] *
1;

fin.seekg(address*sizeof(buf));

//read the directory record's sector!!
fin.read(buf,204;

//now that the directory record is loaded you can find all the files and
print
//their parameters!
fin.close();
}




please help me to complete this C++ code

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
I need to write Simple JAVA program to read and write from USB serialto use it with Arduino sahm Java 4 10-15-2012 06:24 PM
read a ruby script like you would read a text file Mmcolli00 Mom Ruby 2 01-27-2009 10:52 PM
I have one ASP.NET Page. It's for display customer information. Now I want this page to handle the function "Edit" and "Display", Is it possible? Benny Ng ASP .Net 1 01-04-2007 08:00 PM
how to read the information of a file(.dat),and use them in a program. goosen_cug C++ 2 07-03-2006 04:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57