source\lib\gtpublisher\utils.g
1 /******************************************************************************
2 *
3 * Copyright (C) 2007, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * Author: Alexey Krivonogov ( gentee )
11 *
12 ******************************************************************************/
13
14 func uint fileupdate( str filename, buf data )
15 {
16 uint ret
17 file ifile
18 str dir
19
20 verifypath( dir.fgetdir( filename ), 0->arrstr )
21 ifile.open( filename, $OP_ALWAYS )
22 if ifile.getsize() != *data : ret = 1
23 else
24 {
25 buf btemp
26
27 ifile.read( btemp, 0xFFFFFFFF )
28 ret = mcmp( btemp.ptr(), data.ptr(), *data )
29 }
30 ifile.close()
31 if ret : ret = data.write( filename )
32 return ret
33 }
34
35 func uint fileupdate( str filename data )
36 {
37 uint ret
38
39 data.use--
40 ret = fileupdate( filename, data->buf )
41 data.use++
42 return ret
43 }
44