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

Markus Schwarzenberg schwarzb at ipms.fraunhofer.de
Fri Mar 28 13:43:31 UTC 2008


On Fri, 28 Mar 2008 15:07:21 +0700 Patrick Shirkey <pshirkey at boosthardware.com> wrote:

> Hi,
> 
> Can anyone point me to a library that lets me mount a disk, copy data to 
> the disk and unmount the disk?

regarding cp: if you do this in c++, you might want to use 

  boost::filesystem::copy_file()

it's very c++ish, (see below) and less platform dependent.
See http://www.boost.org/libs/filesystem/doc/index.htm
There is a lot of nice stuff there ...

Complete example: 

Source File: copy_file.cc
  #include <boost/filesystem/operations.hpp>
  int main(void) 
  {
    boost::filesystem::path p("file1");
    boost::filesystem::path p2("file2");
    boost::filesystem::copy_file(p, p2);
    return 0;
  }

compile: 
%  g++ copy_file.cc  -l boost_filesystem
  
try out:

% ./a.out 
terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::copy_file: "file1", "file2": No such file or directory
Aborted

# OK, create the missing file and try again:
% touch file1
% ls file?
file1
% ./a.out 
% ls file?
file1  file2

# Try once more
% ./a.out 
terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::copy_file: "file1", "file2": File exists
Aborted

--
Markus Schwarzenberg




More information about the Linux-audio-dev mailing list