This is a discussion on How do you use 'cdrw' within an application? within the Sun Solaris Hardware forums, part of the Solaris Operating System category; --> I'm using a Plextor PX-W1210TSE CD-RW drive on a Solaris 8 system. I'm writing an application in C++ and ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I'm using a Plextor PX-W1210TSE CD-RW drive on a Solaris 8 system. I'm writing an application in C++ and need to be able to burn files/image to a CD from within the application. 'cdrw' may be able to be used, but it's a command-line command. I may be able to use the "system" operation: i.e. system("mkisofs -r <directory> 2>/tmp/cdrw_log | cdrw -i -p 4"); But errors can not be returned to the calling application. This will only work in the "happy day" scenario. Does anyone know how to write/burn files from inside an application? Surely, there must be a cleaner way. M Sudderh msudderth@sfa.com |
| |||
| M Sudderth wrote: > I'm using a Plextor PX-W1210TSE CD-RW drive on a Solaris 8 system. > > I'm writing an application in C++ and need to be able to burn > files/image to a CD from within the application. > > 'cdrw' may be able to be used, but it's a command-line command. I may > be able to use the "system" operation: > i.e. > system("mkisofs -r <directory> 2>/tmp/cdrw_log | cdrw -i -p 4"); > > But errors can not be returned to the calling application. This will > only > work in the "happy day" scenario. The proper thing to do would be to create a pipe using pipe(). Then, for mkisofs, do a fork() and connect the child process's input to /dev/null and stdout to the input end of the pipe (and close the output end of the pipe in that process). Then do something similar for cdrw: fork(), open() of /dev/null and replace stdout with that (using dup2() after closing stdout, if I recall correctly), close the input end of the pipe, connect stdin to the output end of the pipe, then exec() cdrw. Finally, in the parent, close both ends of the pipe (since only the children need it), and wait() on both the children. The wait() call will allow you to retrieve the exit code of both child processes, and this will allow you to determine if the process worked or not. Where you send stderr is another question. You could send it to /dev/null or to a log file or to a second pipe that your application reads if you want. Alternately, write a shell script that does the right thing given the desired parameters, checks the result code of both processes in the pipe, and returns a single exit code indicating failure of success. Then just fork() and exec() that shell script. Or popen() the shell script and make it spit out a summary of what happened on its stdout, then read the summary via pipe. - Logan |
| |||
| In article <DnQyb.69828$Ek.60053@twister.austin.rr.com>, Logan Shaw <lshaw-usenet@austin.rr.com> wrote: >M Sudderth wrote: > >> I'm using a Plextor PX-W1210TSE CD-RW drive on a Solaris 8 system. >> >> I'm writing an application in C++ and need to be able to burn >> files/image to a CD from within the application. >> >> 'cdrw' may be able to be used, but it's a command-line command. I may >> be able to use the "system" operation: >> i.e. >> system("mkisofs -r <directory> 2>/tmp/cdrw_log | cdrw -i -p 4"); >> >> But errors can not be returned to the calling application. This will >> only >> work in the "happy day" scenario. > >The proper thing to do would be to create a pipe using pipe(). >Then, for mkisofs, do a fork() and connect the child process's >input to /dev/null and stdout to the input end of the pipe >(and close the output end of the pipe in that process). Then ..... From listening to some problems with cdrw in the past, it seems that "cdrw" does not necessarily print an error message when something did go wrong. I am not sure if the exit code will be != 0 in such a case.... cdrecord will always print a readable error message and exit != 0 if there was an error. Installing a recent cdrtools package (current is 2.01a19) grants you also that you use a recent and best bug free version of mkisofs. Note that even the next version of Solaris 9 will include only mkisofs-1.14 which is now more than 2 years old. Be sure that you use the mkisofs that comes with the cdrtools package and not /usr/bin/mkisofs P.S. meet me at SunNetwork in Berlin -- EMail:joerg@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin js@cs.tu-berlin.de (uni) If you don't have iso-8859-1 schilling@fokus.fraunhofer.de (work) chars I am J"org Schilling URL: http://www.fokus.fraunhofer.de/usr/schilling ftp://ftp.berlios.de/pub/schily |
| |||
| "M Sudderth" <msudderth@sfa.com> wrote in message news:d728b871.0312011303.19746d8c@posting.google.c om... > I'm using a Plextor PX-W1210TSE CD-RW drive on a Solaris 8 system. > > I'm writing an application in C++ and need to be able to burn > files/image to a CD from within the application. > > 'cdrw' may be able to be used, but it's a command-line command. I may > be able to use the "system" operation: > i.e. > system("mkisofs -r <directory> 2>/tmp/cdrw_log | cdrw -i -p 4"); > > But errors can not be returned to the calling application. This will > only > work in the "happy day" scenario. > > Does anyone know how to write/burn files from inside an application? > > Surely, there must be a cleaner way. You could use fork(), exec() and waitpid() > M Sudderh > msudderth@sfa.com -- Noel R. Nihill UNIX® platform development Motorola NSS I *could* be arguing in my spare time |
| ||||
| Noel R. Nihill wrote: >"M Sudderth" <msudderth@sfa.com> wrote in message >news:d728b871.0312011303.19746d8c@posting.google. com... > > >>I'm using a Plextor PX-W1210TSE CD-RW drive on a Solaris 8 system. >> >>I'm writing an application in C++ and need to be able to burn >>files/image to a CD from within the application. >> >>'cdrw' may be able to be used, but it's a command-line command. I may >>be able to use the "system" operation: >> i.e. >> system("mkisofs -r <directory> 2>/tmp/cdrw_log | cdrw -i -p 4"); >> >>But errors can not be returned to the calling application. This will >>only >>work in the "happy day" scenario. >> >>Does anyone know how to write/burn files from inside an application? >> >>Surely, there must be a cleaner way. >> >> > >You could use fork(), exec() and waitpid() > > > Use popen(3C) to read back the output. Pete. > > > > |
| Thread Tools | |
| Display Modes | |
|
|