1 |
foucault |
27 |
//---------------------------------------------------------------------------
|
2 |
|
|
#include <string.h>
|
3 |
|
|
#include <iostream>
|
4 |
|
|
#include <fstream>
|
5 |
|
|
|
6 |
|
|
#pragma hdrstop
|
7 |
|
|
|
8 |
foucault |
176 |
#include "gestionversion.h"
|
9 |
|
|
|
10 |
foucault |
27 |
#include "CAD4FE_FileUtils.h"
|
11 |
|
|
//---------------------------------------------------------------------------
|
12 |
|
|
#pragma package(smart_init)
|
13 |
|
|
|
14 |
|
|
using namespace CAD4FE;
|
15 |
|
|
|
16 |
|
|
int FileUtils::Copy (char * __source, char * __destination)
|
17 |
|
|
{
|
18 |
|
|
std::ifstream fin(__source, std::ios::in | std::ios::binary);
|
19 |
|
|
std::ofstream fout(__destination, std::ios::out | std::ios::binary);
|
20 |
|
|
const int BUFFER_SIZE = 128;
|
21 |
|
|
char buffer[BUFFER_SIZE];
|
22 |
|
|
while (!fin.eof() )
|
23 |
|
|
{
|
24 |
|
|
fin.read( buffer, BUFFER_SIZE);
|
25 |
|
|
if (fin.bad())
|
26 |
|
|
{
|
27 |
|
|
return 0;
|
28 |
|
|
}
|
29 |
|
|
else
|
30 |
|
|
{
|
31 |
|
|
fout.write(buffer, fin.gcount());
|
32 |
|
|
}
|
33 |
|
|
};
|
34 |
|
|
fin.close();
|
35 |
|
|
fout.close();
|
36 |
|
|
return 1;
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
const char * FileUtils::Basename (const char * __filename)
|
40 |
|
|
{
|
41 |
|
|
int pos=0;
|
42 |
|
|
int sizeF = strlen( __filename );
|
43 |
|
|
for (int i=sizeF; i>=0; i--)
|
44 |
|
|
if ( __filename[i] == '\\' || __filename[i] == '/' )
|
45 |
|
|
{ pos = i+1; break; }
|
46 |
|
|
return __filename + pos;
|
47 |
|
|
} |