Click here to Skip to main content
15,867,568 members
Articles / Desktop Programming / MFC

Write a UDF CDR

Rate me:
Please Sign up or sign in to vote.
4.82/5 (12 votes)
22 Jul 2003CPOL1 min read 252.2K   2.5K   39   91
How to write a CDR in UDF

Image 1

Introduction

Some electronic devices need to use CDR as storage media, and you have to append several files each time before the space is used out. In this case, UDF is a good solution, since for each writing, only 7 logic blocks of overhead are used. (Multisession CDs use several minutes for each session's leadout)

 

How to use the demo

(You need WNASPI32.dll to run the demo, which could be downloaded from Ahead.)

  • Select the CDR drive you want to write to.
  • Insert a blank disc, "Format" it.
  • Browse to select files, and write to the disc. (Now you can view the files using DirectCD).
  • You can list the content of the CDR, and restore files to hard disk
  • Close Session, now any CD drive can read it..

 

How to use the source code

//Create a variable for your drive
SCSI2 m_drive;
//m_HA:HostAdpaterNumber,m_ID:SCSI ID,m_LUN:LogicUnitNumber
m_drive.SCSISelectDevice(m_HA,m_ID,m_LUN);
//For a blank CDR, you need to format it 
m_drive.FormatDisc("VOL1");
//Then you can write files onto it
m_drive.WriteFiles("Test1.bmp");
//Append more files here...
//
//After you have writen ALL the files, close the session
m_drive.CloseSession();
//Now it's readable by regular CDROM drive.

 

Some useful functions

SCSIRead()      //Read data from CDR
WritePacket()      //Write packets to CDR
ReadTrackInfo()      //Read track info, like next writable address
ReadDiskInfo()      //Read disc info, like capacity
TestUnitReady()      //See if the drive is ready
LoadUnload()      //Eject/Close the tray
SetWriteParameters()    //Set write mode
SCSISetSpeed()      //Set read/write speed
ListFiles()      //List files on the CDR
SaveFileAs()      //Save file on CDR to hard disk

If you want to know more inside stuff

Things you need to have:

  • SCSI command block structure (ANSI X3.131-1994)
  • SCSI multimedia commands-2 (ANSI NCITS 333-2000)
  • OSTA specs: ECMA-167, Universal Disk Format Specification, ECMA-119

Things you need to know:

  • SCSI2 block command structure
  • Use of ASPI
  • Concepts about CDR: track, session, logical blocks, PMA, ATIP, TOC, write modes...
  • UDF(Volume structure, file system)

More info at my website.

Revision History

  • Ver 1.01
    • More comments, some code clean up
    • New function: ListFiles()
    • New function: SaveFileAs()
  • Ver 1.02
    • Some changes on the demo application

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
United States United States
Wheels I reinvented on various embedded systems

*License Plate Reader
*TCP/IP stack
*Web Server
*HTTP/FTP/SMTP client
*Ethernet/SCSI/USB drivers
*FAT32/UDF file system
*JPEG/MJPEG encoder

Comments and Discussions

 
Questionload library WNASPI32.DLL not found Pin
jyotisawakare1-May-18 19:25
jyotisawakare1-May-18 19:25 
GeneralNot working in Release mode Pin
Abinash Mohanty17-Aug-09 19:23
Abinash Mohanty17-Aug-09 19:23 
GeneralRe:DVD-RAM FAT32 format in xp Pin
rrbhuvan10-Aug-07 4:33
rrbhuvan10-Aug-07 4:33 
Generalno load Pin
Anima_in_Bofekor24-Nov-05 19:16
Anima_in_Bofekor24-Nov-05 19:16 
QuestionHow many copies make by the CDR Pin
ThangaDharma5-Oct-05 7:22
ThangaDharma5-Oct-05 7:22 
GeneralClose Session Problem Pin
gzu5323-Aug-05 4:24
gzu5323-Aug-05 4:24 
GeneralCode corrections Pin
nico0418-Aug-04 22:18
nico0418-Aug-04 22:18 
QuestionHow to append files to a UDF CDR Pin
jacmod10-Aug-04 17:46
jacmod10-Aug-04 17:46 
AnswerClose session Error: Pin
jacmod25-Aug-04 17:52
jacmod25-Aug-04 17:52 
GeneralError in "Write Files" Process Pin
jacmod5-Jul-04 22:30
jacmod5-Jul-04 22:30 
GeneralRe: Error in "Write Files" Process Pin
Anonymous15-Jul-04 20:34
Anonymous15-Jul-04 20:34 
GeneralRe: Error in "Write Files" Process Pin
jacmod28-Jul-04 17:19
jacmod28-Jul-04 17:19 
GeneralRe: Error in "Write Files" Process Pin
Anonymous29-Jul-04 1:28
Anonymous29-Jul-04 1:28 
GeneralRe: Error in "Write Files" Process Pin
jacmod10-Aug-04 17:29
jacmod10-Aug-04 17:29 
GeneralRe: Error in "Write Files" Process Pin
Tuan Hung 202129-Apr-21 8:15
Tuan Hung 202129-Apr-21 8:15 
GeneralError in SetWriteParameters() function Pin
sunil samineni24-Jun-04 0:37
sunil samineni24-Jun-04 0:37 
GeneralRe: Error in SetWriteParameters() function Pin
fullluck1-Jul-04 21:28
fullluck1-Jul-04 21:28 
Generalexplain note 4 in ATAPI code fix Pin
fkking25-May-04 13:13
fkking25-May-04 13:13 
GeneralRe: explain note 4 in ATAPI code fix Pin
fullluck27-May-04 1:20
fullluck27-May-04 1:20 
GeneralRe: explain note 4 in ATAPI code fix Pin
fkking28-May-04 10:27
fkking28-May-04 10:27 
QuestionWhat's mean this error code? Pin
holysky10019-May-04 19:20
holysky10019-May-04 19:20 
AnswerRe: What's mean this error code? Pin
fkking25-May-04 13:15
fkking25-May-04 13:15 
GeneralDVD RAM Format Pin
Anonymous12-May-04 5:48
Anonymous12-May-04 5:48 
GeneralRe: DVD RAM Format Pin
nico0416-Aug-04 4:24
nico0416-Aug-04 4:24 
GeneralRe: DVD RAM Format Pin
KenThompson10-Mar-08 3:07
KenThompson10-Mar-08 3:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.