~ubuntu-branches/ubuntu/karmic/firebird2.1/karmic

« back to all changes in this revision

Viewing changes to src/common/classes/TempFile.h

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2008-05-26 23:59:25 UTC
  • Revision ID: james.westby@ubuntu.com-20080526235925-2pnqj6nxpppoeaer
Tags: upstream-2.1.0.17798-0.ds2
ImportĀ upstreamĀ versionĀ 2.1.0.17798-0.ds2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  The contents of this file are subject to the Initial
 
3
 *  Developer's Public License Version 1.0 (the "License");
 
4
 *  you may not use this file except in compliance with the
 
5
 *  License. You may obtain a copy of the License at
 
6
 *  http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
 
7
 *
 
8
 *  Software distributed under the License is distributed AS IS,
 
9
 *  WITHOUT WARRANTY OF ANY KIND, either express or implied.
 
10
 *  See the License for the specific language governing rights
 
11
 *  and limitations under the License.
 
12
 *
 
13
 *  The Original Code was created by Dmitry Yemanov
 
14
 *  for the Firebird Open Source RDBMS project.
 
15
 *
 
16
 *  Copyright (c) 2006 Dmitry Yemanov <dimitr@users.sf.net>
 
17
 *  and all contributors signed below.
 
18
 *
 
19
 *  All Rights Reserved.
 
20
 *  Contributor(s): ______________________________________.
 
21
 */
 
22
 
 
23
#ifndef CLASSES_TEMP_FILE_H
 
24
#define CLASSES_TEMP_FILE_H
 
25
 
 
26
#include "firebird.h"
 
27
#include "../common/classes/fb_string.h"
 
28
#include "../common/classes/File.h"
 
29
 
 
30
class TempFile : public Firebird::File {
 
31
public:
 
32
        TempFile(MemoryPool& pool,
 
33
                         const Firebird::PathName& prefix,
 
34
                         const Firebird::PathName& directory,
 
35
                         bool do_unlink = true)
 
36
                : filename(pool), position(0), size(0), doUnlink(do_unlink)
 
37
        {
 
38
                init(directory, prefix);
 
39
        }
 
40
 
 
41
        TempFile(const Firebird::PathName& prefix,
 
42
                         bool do_unlink = true)
 
43
                : position(0), size(0), doUnlink(do_unlink)
 
44
        {
 
45
                init("", prefix);
 
46
        }
 
47
 
 
48
        virtual ~TempFile();
 
49
 
 
50
        size_t read(offset_t, void*, size_t);
 
51
        size_t write(offset_t, void*, size_t);
 
52
 
 
53
        void unlink();
 
54
 
 
55
        offset_t getSize() const
 
56
        {
 
57
                return size;
 
58
        }
 
59
 
 
60
        void extend(size_t);
 
61
 
 
62
        const Firebird::PathName& getName() const
 
63
        {
 
64
                return filename;
 
65
        }
 
66
 
 
67
        static Firebird::PathName getTempPath();
 
68
        static Firebird::PathName create(const Firebird::PathName&);
 
69
 
 
70
private:
 
71
        void init(const Firebird::PathName&, const Firebird::PathName&);
 
72
        void seek(offset_t);
 
73
 
 
74
#if defined(WIN_NT)
 
75
        HANDLE handle;
 
76
#else
 
77
        int handle;
 
78
#endif
 
79
 
 
80
        Firebird::PathName filename;
 
81
        offset_t position;
 
82
        offset_t size;
 
83
        bool doUnlink;
 
84
};
 
85
 
 
86
#endif // CLASSES_TEMP_FILE_H