Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying file to a mounted file system

Status
Not open for further replies.

tewari68

Programmer
Jan 25, 2005
87
0
0
US
Hi,
I am using the following code to copy a file from one source folder to a destination folder
Code:
string filname;
  
    string::size_type start = emailDestination.find("tmp/");
    string::size_type end = emailDestination.find("\n");
    filname = emailDestination.substr(start + 4,end);
    cout << "fileName is : " << filname << endl;
    finalEmailDestination = finalEmailDestination + filname;
     
  char ch;
  std::ifstream infile;
  std::ofstream outfile;
  filebuf *inbuf, *outbuf;
  infile.open (emailDestination.c_str(), ios::in);
  outfile.open (finalEmailDestination.c_str(), ios::out);
   inbuf=infile.rdbuf();
  outbuf=outfile.rdbuf();

  ch = inbuf->sgetc();
  while ( ch != EOF)
  {
    outbuf->sputc (ch);
    ch= inbuf->snextc();
  }
this works fine if the directories are on a local drive, however I have to move the file from the local tmp directory to a directory on a mounted file system, what changes do I have to make in the above code to achieve this.
Also I want some error checking to be sure that the file has been copied successfully to the destination directory.
Thanks in advance,
tewari
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top