~ubuntu-branches/ubuntu/hardy/steam/hardy

« back to all changes in this revision

Viewing changes to server/kernel/DocFile.pike

  • Committer: Bazaar Package Importer
  • Author(s): Alain Schroeder
  • Date: 2006-11-21 16:03:12 UTC
  • mfrom: (2.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061121160312-nf96y6nihzsyd2uv
Tags: 2.2.31-3
Add patch to prevent inconsistent data after shutdown.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000-2004  Thomas Bopp, Thorsten Hampel, Ludger Merkens
 
1
/* Copyright (C) 2000-2006  Thomas Bopp, Thorsten Hampel, Ludger Merkens
2
2
 *
3
3
 *  This program is free software; you can redistribute it and/or modify
4
4
 *  it under the terms of the GNU General Public License as published by
14
14
 *  along with this program; if not, write to the Free Software
15
15
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
16
 * 
17
 
 * $Id: DocFile.pike,v 1.1.1.1 2005/02/23 14:47:21 cvs Exp $
 
17
 * $Id: DocFile.pike,v 1.2 2006/10/03 13:02:07 astra Exp $
18
18
 */
19
19
 
20
 
constant cvs_version="$Id: DocFile.pike,v 1.1.1.1 2005/02/23 14:47:21 cvs Exp $";
 
20
constant cvs_version="$Id: DocFile.pike,v 1.2 2006/10/03 13:02:07 astra Exp $";
21
21
 
22
22
#include <classes.h>
23
23
#include <database.h>
40
40
static function  contentRead; // read content from this function
41
41
static function contentWrite; // write content to this function
42
42
static string      sProtocol;
 
43
static int     last_response;
43
44
 
44
45
int error = 0;
45
46
 
51
52
    buffer = "";
52
53
    position = 0;
53
54
    doc_position = 0;
 
55
    last_response = time();
54
56
    if ( !stringp(type) )
55
57
        type = "r";
56
58
 
 
59
    if ( document->get_object_class() & CLASS_LINK ) 
 
60
      document = document->get_link_object();
 
61
 
57
62
    if ( search(type, "r") >= 0 && 
58
63
         document->get_object_class() & CLASS_DOCUMENT ) 
59
64
    {
78
83
 
79
84
int is_file() { return steamObject->get_object_class() & CLASS_DOCUMENT; }
80
85
int is_dir() { return steamObject->get_object_class() & CLASS_CONTAINER; }
 
86
int get_last_response() { return last_response; }
81
87
 
82
88
int write(string data)
83
89
{
 
90
    last_response = time();
84
91
    if ( !functionp(contentWrite) )
85
92
        contentWrite = steamObject->receive_content(0);
86
93
 
90
97
 
91
98
void close()
92
99
{
 
100
  destruct(this_object());
 
101
}
 
102
 
 
103
void destroy()
 
104
{
93
105
  if ( functionp(contentWrite) ) {
94
106
    catch(contentWrite(0));
95
107
  }
 
108
 
 
109
  if ( functionp(contentRead) ) {
 
110
      object obj = function_object(contentRead);
 
111
      if ( objectp(obj) )
 
112
          catch(obj->close());
 
113
  }
96
114
  contentWrite = 0;
97
115
  position = 0;
98
116
  contentRead = 0;
99
117
  doc_position = 0;
100
 
  destruct(this_object());
101
118
}
102
119
 
103
120
static int fill_buffer(int how_much)
137
154
 
138
155
string read(void|int len, void|int not_all)
139
156
{
 
157
    last_response = time();
140
158
    if ( position == _sizeof() ) {
141
159
        position++;
142
160
        return "";
168
186
{
169
187
  int offset = pos - position;
170
188
 
171
 
  fill_buffer(_sizeof());
 
189
  //fill_buffer(_sizeof());
 
190
  fill_buffer(offset + 65536);
172
191
  // cut everything from current position
173
192
  buffer = buffer[offset..];
174
193
  position = pos;
196
215
    if ( !arrayp(res) )
197
216
      res = steamObject->stat();
198
217
    Stdio.Stat st = Stdio.Stat();
199
 
    st->atime = res[3];
200
 
    st->mtime = res[4];
 
218
    st->atime = res[4];
 
219
    st->mtime = res[3];
201
220
    st->ctime = res[2];
202
221
    st->gid   = res[5];
203
222
    st->mode  = res[0];