LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-16-2007, 11:47 PM   #1
jaepi
Member
 
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189
Blog Entries: 1

Rep: Reputation: 30
how will you know if a cd-rw has a data inside?


hello there, i'm currently making a program that will burn an iso file...before burning the file, how would you know if the medium (preferably a cd-rw) has a file written inside? what functions/commands could i or should i use? thanks...

Last edited by jaepi; 05-17-2007 at 01:35 AM.
 
Old 05-17-2007, 12:55 AM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
You could try to mount it and see if it can.
 
Old 05-17-2007, 01:40 AM   #3
jaepi
Member
 
Registered: Apr 2007
Location: Urban Jungle
Distribution: Ubuntu
Posts: 189

Original Poster
Blog Entries: 1

Rep: Reputation: 30
Quote:
Originally Posted by Matir
You could try to mount it and see if it can.
uhmmm...im using c++ sir...how do use mount in my flow control statements?

if(cd-rw is empty){
burn files
}else{
empty the cd
burn files
}

i hope you know what i mean...
 
Old 05-17-2007, 08:51 AM   #4
Dox Systems - Brian
Member
 
Registered: Nov 2006
Posts: 344

Rep: Reputation: 31
You *can* exec mount and see what it returns from within c++.

Not an ideal solution of course, but it's *a* way to do it.
 
Old 05-17-2007, 08:57 AM   #5
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 200

Rep: Reputation: 30
You don't need to call the external mount program to mount a drive. Mount is a system call ( sys_mount (21) ) and it's available through sys/mount.h for the user space.
Try
Code:
man 2 mount
and you'll see :

Code:
       #include <sys/mount.h>

       int mount(const char *source, const char *target,
                 const char *filesystemtype, unsigned long mountflags,
                 const void *data);

       int umount(const char *target);
And actually, if you are considering also the situation when CD has a proper ISO filesystem on it but there're no files, then you need to check for the files. My choice would be the opendir and readdir commands. See man 2 readdir and man 3 opendir.

Last edited by krizzz; 05-17-2007 at 09:03 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gnuplot, pull X data from file, specify Y data at cmd line? hedpe Programming 5 03-15-2007 11:32 PM
LXer: Inside Second Life's Data Centers LXer Syndicated Linux News 0 03-06-2007 01:16 AM
iptables inside client to inside host with outside DNS or IP - Help! linuxhelp2 Linux - Networking 1 10-15-2005 06:19 AM
ADSL connects but no data transmits, info inside... DaveQB Mandriva 2 11-09-2003 10:59 AM
retriving mysql data, and placing it inside a table in html using perl rhuser Programming 1 03-12-2003 05:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration