[LAD] OT.C Library for mounting, processing data

Christian Schoenebeck cuse at users.sourceforge.net
Fri Mar 28 10:28:38 UTC 2008


Am Freitag, 28. März 2008 09:37:35 schrieben Sie:
> Christian Schoenebeck wrote:
> > Am Freitag, 28. März 2008 09:07:21 schrieb Patrick Shirkey:
> >> Hi,
> >>
> >> Can anyone point me to a library that lets me mount a disk, copy data to
> >> the disk and unmount the disk?
> >>
> >> I'm using c and gtk.
> >
> > Uhm... how about the short way:
> >
> > #include <stdlib.h>
> >
> > int main() {
> >     system("mount /dev/foo /bar");
> >     system("cp this there");
> >     system("umount /bar");
> > }
>
> Hi,
>
> That is a useful tip. Thanks.
>
> If I wanted to get a bit more detail from the transfer process what
> would be the more elegant approach?

Then just replace the

	system("cp this there");

line with something more "ambitious". There are many ways to do that of 
course. For example using standard C fopen(), fread(), fwrite() and fclose() 
calls and calculate the current progress in your C code by yourself, based on 
the current read/write position.

Or you could simply use the function g_file_copy() from glib, which also 
conveniently supports callback functions to update a progress bar:

http://library.gnome.org/devel/gio/unstable/GFile.html#id2997501

or use the C++ derivate from glibmm:

http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGio_1_1File.html#1d8159b5b377db174b376b3c09deb7c1

CU
Christian



More information about the Linux-audio-dev mailing list