ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/extfs_unix.cpp
Revision: 1.3
Committed: 1999-10-21T22:40:01Z (24 years, 8 months ago) by cebix
Branch: MAIN
Changes since 1.2: +15 -0 lines
Log Message:
- ExtFS works under AmigaOS
- fixed erroneous __regargs attributes in prefs_editor_amiga.cpp
  and audio_amiga.cpp for GCC

File Contents

# Content
1 /*
2 * extfs_unix.cpp - MacOS file system for access native file system access, Unix specific stuff
3 *
4 * Basilisk II (C) 1997-1999 Christian Bauer
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 #include <sys/types.h>
22 #include <sys/stat.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <unistd.h>
26 #include <dirent.h>
27 #include <errno.h>
28
29 #include "sysdeps.h"
30 #include "extfs.h"
31 #include "extfs_defs.h"
32
33 #define DEBUG 0
34 #include "debug.h"
35
36
37 // Default Finder flags
38 const uint16 DEFAULT_FINDER_FLAGS = kHasBeenInited;
39
40
41 /*
42 * Initialization
43 */
44
45 void extfs_init(void)
46 {
47 }
48
49
50 /*
51 * Deinitialization
52 */
53
54 void extfs_exit(void)
55 {
56 }
57
58
59 /*
60 * Add component to path name
61 */
62
63 void add_path_component(char *path, const char *component, int max_len)
64 {
65 int l = strlen(path);
66 if (l < max_len-1 && path[l-1] != '/') {
67 path[l] = '/';
68 path[l+1] = 0;
69 }
70 strncat(path, s, max_len-1);
71 }
72
73
74 /*
75 * Get/set finder type/creator for file specified by full path
76 */
77
78 struct ext2type {
79 const char *ext;
80 uint32 type;
81 uint32 creator;
82 };
83
84 static const ext2type e2t_translation[] = {
85 {".Z", 'ZIVM', 'LZIV'},
86 {".gz", 'Gzip', 'Gzip'},
87 {".hqx", 'TEXT', 'SITx'},
88 {".pdf", 'PDF ', 'CARO'},
89 {".ps", 'TEXT', 'ttxt'},
90 {".sit", 'SIT!', 'SITx'},
91 {".tar", 'TARF', 'TAR '},
92 {".uu", 'TEXT', 'SITx'},
93 {".uue", 'TEXT', 'SITx'},
94 {".zip", 'ZIP ', 'ZIP '},
95 {".8svx", '8SVX', 'SNDM'},
96 {".aifc", 'AIFC', 'TVOD'},
97 {".aiff", 'AIFF', 'TVOD'},
98 {".au", 'ULAW', 'TVOD'},
99 {".mid", 'MIDI', 'TVOD'},
100 {".midi", 'MIDI', 'TVOD'},
101 {".mp2", 'MPG ', 'TVOD'},
102 {".mp3", 'MPG ', 'TVOD'},
103 {".wav", 'WAVE', 'TVOD'},
104 {".bmp", 'BMPf', 'ogle'},
105 {".gif", 'GIFf', 'ogle'},
106 {".lbm", 'ILBM', 'GKON'},
107 {".ilbm", 'ILBM', 'GKON'},
108 {".jpg", 'JPEG', 'ogle'},
109 {".jpeg", 'JPEG', 'ogle'},
110 {".pict", 'PICT', 'ogle'},
111 {".png", 'PNGf', 'ogle'},
112 {".sgi", '.SGI', 'ogle'},
113 {".tga", 'TPIC', 'ogle'},
114 {".tif", 'TIFF', 'ogle'},
115 {".tiff", 'TIFF', 'ogle'},
116 {".html", 'TEXT', 'MOSS'},
117 {".txt", 'TEXT', 'ttxt'},
118 {".rtf", 'TEXT', 'MSWD'},
119 {".c", 'TEXT', 'R*ch'},
120 {".C", 'TEXT', 'R*ch'},
121 {".cc", 'TEXT', 'R*ch'},
122 {".cpp", 'TEXT', 'R*ch'},
123 {".cxx", 'TEXT', 'R*ch'},
124 {".h", 'TEXT', 'R*ch'},
125 {".hh", 'TEXT', 'R*ch'},
126 {".hpp", 'TEXT', 'R*ch'},
127 {".hxx", 'TEXT', 'R*ch'},
128 {".s", 'TEXT', 'R*ch'},
129 {".S", 'TEXT', 'R*ch'},
130 {".i", 'TEXT', 'R*ch'},
131 {".mpg", 'MPEG', 'TVOD'},
132 {".mpeg", 'MPEG', 'TVOD'},
133 {".mov", 'MooV', 'TVOD'},
134 {".fli", 'FLI ', 'TVOD'},
135 {".avi", 'VfW ', 'TVOD'},
136 {NULL, 0, 0} // End marker
137 };
138
139 void get_finder_type(const char *path, uint32 &type, uint32 &creator)
140 {
141 type = 0;
142 creator = 0;
143
144 // Translate file name extension to MacOS type/creator
145 int path_len = strlen(path);
146 for (int i=0; e2t_translation[i].ext; i++) {
147 int ext_len = strlen(e2t_translation[i].ext);
148 if (path_len < ext_len)
149 continue;
150 if (!strcmp(path + path_len - ext_len, e2t_translation[i].ext)) {
151 type = e2t_translation[i].type;
152 creator = e2t_translation[i].creator;
153 break;
154 }
155 }
156 }
157
158 void set_finder_type(const char *path, uint32 type, uint32 creator)
159 {
160 }
161
162
163 /*
164 * Get/set finder flags for file/dir specified by full path (MACOS:HFS_FLAGS attribute)
165 */
166
167 void get_finder_flags(const char *path, uint16 &flags)
168 {
169 flags = DEFAULT_FINDER_FLAGS; // Default
170 }
171
172 void set_finder_flags(const char *path, uint16 flags)
173 {
174 }
175
176
177 /*
178 * Resource fork emulation functions
179 */
180
181 uint32 get_rfork_size(const char *path)
182 {
183 return 0;
184 }
185
186 int open_rfork(const char *path, int flag)
187 {
188 return -1;
189 }
190
191 void close_rfork(const char *path, int fd)
192 {
193 }
194
195
196 /*
197 * Read "length" bytes from file to "buffer",
198 * returns number of bytes read (or 0)
199 */
200
201 size_t extfs_read(int fd, void *buffer, size_t length)
202 {
203 errno = 0;
204 return read(fd, buffer, length);
205 }
206
207
208 /*
209 * Write "length" bytes from "buffer" to file,
210 * returns number of bytes written (or 0)
211 */
212
213 size_t extfs_write(int fd, void *buffer, size_t length)
214 {
215 errno = 0;
216 return write(fd, buffer, length);
217 }