source: golgotha/src/i4/file/saturn/sat_file.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 14 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 3.2 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "file/file.hh"
10#include "error/error.hh"
11
12#include "file/buf_file.hh"
13
14#ifdef _SATURN
15extern "C"
16{
17#include "libsn.h"
18};
19#endif
20
21
22class i4_saturn_file_class : public i4_file_class
23//{{{
24{
25  w32 fd;
26  public :
27  i4_saturn_file_class(w32 fd) : fd(fd) {}
28
29  virtual w32 read (void *buffer, w32 size)
30  //{{{
31  {
32    w32 ret=PCread(fd,(char *)buffer,size);
33    return ret;
34  }
35  //}}}
36
37  virtual w32 write(void *buffer, w32 size) {}
38
39  virtual w32 seek (w32 offset)               
40  //{{{
41  {
42    PClseek(fd,offset,0);
43  }
44  //}}}
45
46  virtual w32 size ()                       
47  //{{{
48  {
49   
50    w32 cur=PClseek(fd,0,SEEK_CUR);
51    w32 len=PClseek(fd,0,SEEK_END);
52    PClseek(fd,cur,SEEK_SET);
53    return len;
54  }
55  //}}}
56
57  virtual w32 tell ()                       
58  //{{{
59  {
60    w32 ret=PClseek(fd,0,SEEK_CUR);
61    return ret;
62  }
63  //}}}
64
65  ~i4_saturn_file_class()                   
66  //{{{
67  {
68    PCclose(fd);
69  }
70  //}}}
71};
72//}}}
73
74
75char *i4_os_string(const i4_const_str &name);
76
77i4_file_class *i4_file_manager_class::default_open(const i4_const_str &name, w32 flags)
78//{{{
79{
80  sw32 f=0;
81  i4_bool no_buffer=i4_F;
82
83  if (flags & NO_BUFFER)
84  {
85    flags=(file_flags)(flags & (~NO_BUFFER));
86    no_buffer=i4_T;
87  }
88
89  switch (flags)
90  {
91    case READ:
92      break;
93
94    default:
95      i4_warning("i4_file_class::Bad open flags!");
96      return NULL;     
97  }
98
99  int fd;
100
101
102  fd=PCopen(i4_os_string(name),0,0);
103
104  if (fd<0)
105  {
106    i4_warning("i4_file_class::open failed for %s\n",i4_os_string(name));
107    return NULL;
108  }
109
110
111  i4_file_class *ret_fp;
112  if (!no_buffer)
113    ret_fp=new i4_buffered_file_class(new i4_saturn_file_class(fd));
114  else
115    ret_fp=new i4_saturn_file_class(fd);
116
117  return ret_fp;
118}
119//}}}
120
121
122i4_bool i4_file_manager_class::default_unlink(const i4_const_str &name)
123//{{{
124{
125  i4_error("What are you crazy?");
126 
127  return 0;
128}
129//}}}
130
131
132i4_bool i4_file_manager_class::default_get_status(const i4_const_str &name,
133                                                  i4_file_status_struct &return_stat)
134//{{{
135{
136  i4_error("What are you crazy?");
137
138  return 0;
139}
140//}}}
141
142
143i4_bool i4_file_manager_class::default_mkdir(const i4_const_str &name)
144//{{{
145{
146  // What?  Are you crazy?
147  return 0;
148}
149//}}}
150
151
152i4_bool i4_file_manager_class::default_get_directory(const i4_const_str &path,
153                                             i4_str **&files, w32 &tfiles,
154                                             i4_str **&dirs, w32 &tdirs)
155// returns i4_F if path is bad (tfiles and tdirs will be 0 as well)
156//{{{
157{
158  // What?  Are you crazy?
159  return 0;
160}
161//}}}
162
163
164//{{{ Emacs Locals
165// Local Variables:
166// folded-file: t
167// End:
168//}}}
Note: See TracBrowser for help on using the repository browser.