~ubuntu-branches/ubuntu/oneiric/valkyrie/oneiric

« back to all changes in this revision

Viewing changes to valkyrie/vk_file_utils.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Hai Zaar
  • Date: 2009-05-06 14:48:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090506144800-vw617m4d4qa2pam3
Tags: upstream-1.4.0
ImportĀ upstreamĀ versionĀ 1.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ---------------------------------------------------------------------
 
2
 * Custom file dialog                                  vk_file_utils.cpp
 
3
 * ---------------------------------------------------------------------
 
4
 * This file is part of Valkyrie, a front-end for Valgrind
 
5
 * Copyright (C) 2000-2008, OpenWorks LLP <info@open-works.co.uk>
 
6
 * This program is released under the terms of the GNU GPL v.2
 
7
 * See the file COPYING for the full license details.
 
8
 */
 
9
 
 
10
#include "vk_file_utils.h"
 
11
 
 
12
#include <qfile.h>
 
13
 
 
14
 
 
15
/* ------------------------------------------------------------------ */
 
16
bool FileCopy(const QString& in, const QString& out)
 
17
{
 
18
   const int bufSize = 16384; // 16Kb buffer
 
19
   char *buf = new char[bufSize];
 
20
   
 
21
   QFile fin(in);
 
22
   if( !fin.open(IO_ReadOnly) )
 
23
      return false;
 
24
   QFile fout(out);
 
25
   if( !fout.open(IO_WriteOnly) )
 
26
      return false;
 
27
 
 
28
   int len = fin.readBlock(buf, bufSize);
 
29
   while (len > 0) {
 
30
      if (fout.writeBlock(buf, len) == -1)
 
31
         return false;
 
32
      len = fin.readBlock(buf, len);
 
33
   }
 
34
   if (len == -1)
 
35
      return false;
 
36
 
 
37
   fin.close();
 
38
   fout.close();
 
39
   delete[] buf;
 
40
 
 
41
   return true;
 
42
}