1 |
|
/* |
2 |
|
* extfs_amiga.cpp - MacOS file system for access native file system access, AmigaOS specific stuff |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2000 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2008 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 |
19 |
|
*/ |
20 |
|
|
21 |
|
#include <exec/types.h> |
22 |
+ |
#define __USE_SYSBASE |
23 |
|
#include <proto/dos.h> |
24 |
+ |
#include <inline/dos.h> |
25 |
|
|
26 |
|
#include <sys/types.h> |
27 |
|
#include <sys/stat.h> |
155 |
|
}; |
156 |
|
|
157 |
|
static const ext2type e2t_translation[] = { |
158 |
< |
{".Z", 'ZIVM', 'LZIV'}, |
159 |
< |
{".gz", 'Gzip', 'Gzip'}, |
160 |
< |
{".hqx", 'TEXT', 'SITx'}, |
161 |
< |
{".pdf", 'PDF ', 'CARO'}, |
162 |
< |
{".ps", 'TEXT', 'ttxt'}, |
163 |
< |
{".sit", 'SIT!', 'SITx'}, |
164 |
< |
{".tar", 'TARF', 'TAR '}, |
165 |
< |
{".uu", 'TEXT', 'SITx'}, |
166 |
< |
{".uue", 'TEXT', 'SITx'}, |
167 |
< |
{".zip", 'ZIP ', 'ZIP '}, |
168 |
< |
{".8svx", '8SVX', 'SNDM'}, |
169 |
< |
{".aifc", 'AIFC', 'TVOD'}, |
170 |
< |
{".aiff", 'AIFF', 'TVOD'}, |
171 |
< |
{".au", 'ULAW', 'TVOD'}, |
172 |
< |
{".mid", 'MIDI', 'TVOD'}, |
173 |
< |
{".midi", 'MIDI', 'TVOD'}, |
174 |
< |
{".mp2", 'MPG ', 'TVOD'}, |
175 |
< |
{".mp3", 'MPG ', 'TVOD'}, |
176 |
< |
{".wav", 'WAVE', 'TVOD'}, |
177 |
< |
{".bmp", 'BMPf', 'ogle'}, |
178 |
< |
{".gif", 'GIFf', 'ogle'}, |
179 |
< |
{".lbm", 'ILBM', 'GKON'}, |
180 |
< |
{".ilbm", 'ILBM', 'GKON'}, |
181 |
< |
{".jpg", 'JPEG', 'ogle'}, |
182 |
< |
{".jpeg", 'JPEG', 'ogle'}, |
183 |
< |
{".pict", 'PICT', 'ogle'}, |
184 |
< |
{".png", 'PNGf', 'ogle'}, |
185 |
< |
{".sgi", '.SGI', 'ogle'}, |
186 |
< |
{".tga", 'TPIC', 'ogle'}, |
187 |
< |
{".tif", 'TIFF', 'ogle'}, |
188 |
< |
{".tiff", 'TIFF', 'ogle'}, |
189 |
< |
{".htm", 'TEXT', 'MOSS'}, |
190 |
< |
{".html", 'TEXT', 'MOSS'}, |
191 |
< |
{".txt", 'TEXT', 'ttxt'}, |
192 |
< |
{".rtf", 'TEXT', 'MSWD'}, |
193 |
< |
{".c", 'TEXT', 'R*ch'}, |
194 |
< |
{".C", 'TEXT', 'R*ch'}, |
195 |
< |
{".cc", 'TEXT', 'R*ch'}, |
196 |
< |
{".cpp", 'TEXT', 'R*ch'}, |
197 |
< |
{".cxx", 'TEXT', 'R*ch'}, |
198 |
< |
{".h", 'TEXT', 'R*ch'}, |
199 |
< |
{".hh", 'TEXT', 'R*ch'}, |
200 |
< |
{".hpp", 'TEXT', 'R*ch'}, |
201 |
< |
{".hxx", 'TEXT', 'R*ch'}, |
202 |
< |
{".s", 'TEXT', 'R*ch'}, |
203 |
< |
{".S", 'TEXT', 'R*ch'}, |
204 |
< |
{".i", 'TEXT', 'R*ch'}, |
205 |
< |
{".mpg", 'MPEG', 'TVOD'}, |
206 |
< |
{".mpeg", 'MPEG', 'TVOD'}, |
207 |
< |
{".mov", 'MooV', 'TVOD'}, |
208 |
< |
{".fli", 'FLI ', 'TVOD'}, |
209 |
< |
{".avi", 'VfW ', 'TVOD'}, |
210 |
< |
{".qxd", 'XDOC', 'XPR3'}, |
211 |
< |
{".hfv", 'DDim', 'ddsk'}, |
212 |
< |
{".dsk", 'DDim', 'ddsk'}, |
211 |
< |
{".img", 'rohd', 'ddsk'}, |
158 |
> |
{".z", FOURCC('Z','I','V','M'), FOURCC('L','Z','I','V')}, |
159 |
> |
{".gz", FOURCC('G','z','i','p'), FOURCC('G','z','i','p')}, |
160 |
> |
{".hqx", FOURCC('T','E','X','T'), FOURCC('S','I','T','x')}, |
161 |
> |
{".bin", FOURCC('T','E','X','T'), FOURCC('S','I','T','x')}, |
162 |
> |
{".pdf", FOURCC('P','D','F',' '), FOURCC('C','A','R','O')}, |
163 |
> |
{".ps", FOURCC('T','E','X','T'), FOURCC('t','t','x','t')}, |
164 |
> |
{".sit", FOURCC('S','I','T','!'), FOURCC('S','I','T','x')}, |
165 |
> |
{".tar", FOURCC('T','A','R','F'), FOURCC('T','A','R',' ')}, |
166 |
> |
{".uu", FOURCC('T','E','X','T'), FOURCC('S','I','T','x')}, |
167 |
> |
{".uue", FOURCC('T','E','X','T'), FOURCC('S','I','T','x')}, |
168 |
> |
{".zip", FOURCC('Z','I','P',' '), FOURCC('Z','I','P',' ')}, |
169 |
> |
{".8svx", FOURCC('8','S','V','X'), FOURCC('S','N','D','M')}, |
170 |
> |
{".aifc", FOURCC('A','I','F','C'), FOURCC('T','V','O','D')}, |
171 |
> |
{".aiff", FOURCC('A','I','F','F'), FOURCC('T','V','O','D')}, |
172 |
> |
{".au", FOURCC('U','L','A','W'), FOURCC('T','V','O','D')}, |
173 |
> |
{".mid", FOURCC('M','I','D','I'), FOURCC('T','V','O','D')}, |
174 |
> |
{".midi", FOURCC('M','I','D','I'), FOURCC('T','V','O','D')}, |
175 |
> |
{".mp2", FOURCC('M','P','G',' '), FOURCC('T','V','O','D')}, |
176 |
> |
{".mp3", FOURCC('M','P','G',' '), FOURCC('T','V','O','D')}, |
177 |
> |
{".wav", FOURCC('W','A','V','E'), FOURCC('T','V','O','D')}, |
178 |
> |
{".bmp", FOURCC('B','M','P','f'), FOURCC('o','g','l','e')}, |
179 |
> |
{".gif", FOURCC('G','I','F','f'), FOURCC('o','g','l','e')}, |
180 |
> |
{".lbm", FOURCC('I','L','B','M'), FOURCC('G','K','O','N')}, |
181 |
> |
{".ilbm", FOURCC('I','L','B','M'), FOURCC('G','K','O','N')}, |
182 |
> |
{".jpg", FOURCC('J','P','E','G'), FOURCC('o','g','l','e')}, |
183 |
> |
{".jpeg", FOURCC('J','P','E','G'), FOURCC('o','g','l','e')}, |
184 |
> |
{".pict", FOURCC('P','I','C','T'), FOURCC('o','g','l','e')}, |
185 |
> |
{".png", FOURCC('P','N','G','f'), FOURCC('o','g','l','e')}, |
186 |
> |
{".sgi", FOURCC('.','S','G','I'), FOURCC('o','g','l','e')}, |
187 |
> |
{".tga", FOURCC('T','P','I','C'), FOURCC('o','g','l','e')}, |
188 |
> |
{".tif", FOURCC('T','I','F','F'), FOURCC('o','g','l','e')}, |
189 |
> |
{".tiff", FOURCC('T','I','F','F'), FOURCC('o','g','l','e')}, |
190 |
> |
{".htm", FOURCC('T','E','X','T'), FOURCC('M','O','S','S')}, |
191 |
> |
{".html", FOURCC('T','E','X','T'), FOURCC('M','O','S','S')}, |
192 |
> |
{".txt", FOURCC('T','E','X','T'), FOURCC('t','t','x','t')}, |
193 |
> |
{".rtf", FOURCC('T','E','X','T'), FOURCC('M','S','W','D')}, |
194 |
> |
{".c", FOURCC('T','E','X','T'), FOURCC('R','*','c','h')}, |
195 |
> |
{".cc", FOURCC('T','E','X','T'), FOURCC('R','*','c','h')}, |
196 |
> |
{".cpp", FOURCC('T','E','X','T'), FOURCC('R','*','c','h')}, |
197 |
> |
{".cxx", FOURCC('T','E','X','T'), FOURCC('R','*','c','h')}, |
198 |
> |
{".h", FOURCC('T','E','X','T'), FOURCC('R','*','c','h')}, |
199 |
> |
{".hh", FOURCC('T','E','X','T'), FOURCC('R','*','c','h')}, |
200 |
> |
{".hpp", FOURCC('T','E','X','T'), FOURCC('R','*','c','h')}, |
201 |
> |
{".hxx", FOURCC('T','E','X','T'), FOURCC('R','*','c','h')}, |
202 |
> |
{".s", FOURCC('T','E','X','T'), FOURCC('R','*','c','h')}, |
203 |
> |
{".i", FOURCC('T','E','X','T'), FOURCC('R','*','c','h')}, |
204 |
> |
{".mpg", FOURCC('M','P','E','G'), FOURCC('T','V','O','D')}, |
205 |
> |
{".mpeg", FOURCC('M','P','E','G'), FOURCC('T','V','O','D')}, |
206 |
> |
{".mov", FOURCC('M','o','o','V'), FOURCC('T','V','O','D')}, |
207 |
> |
{".fli", FOURCC('F','L','I',' '), FOURCC('T','V','O','D')}, |
208 |
> |
{".avi", FOURCC('V','f','W',' '), FOURCC('T','V','O','D')}, |
209 |
> |
{".qxd", FOURCC('X','D','O','C'), FOURCC('X','P','R','3')}, |
210 |
> |
{".hfv", FOURCC('D','D','i','m'), FOURCC('d','d','s','k')}, |
211 |
> |
{".dsk", FOURCC('D','D','i','m'), FOURCC('d','d','s','k')}, |
212 |
> |
{".img", FOURCC('r','o','h','d'), FOURCC('d','d','s','k')}, |
213 |
|
{NULL, 0, 0} // End marker |
214 |
|
}; |
215 |
|
|
216 |
< |
void get_finfo(const char *path, uint32 finfo, uint32 fxinfo) |
216 |
> |
void get_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir) |
217 |
|
{ |
218 |
|
// Set default finder info |
219 |
|
Mac_memset(finfo, 0, SIZEOF_FInfo); |
234 |
|
} |
235 |
|
|
236 |
|
// No Finder info file, translate file name extension to MacOS type/creator |
237 |
< |
struct stat st; |
237 |
< |
if (stat(path, &st) == 0 && !S_ISDIR(st.st_mode)) { |
237 |
> |
if (!is_dir) { |
238 |
|
int path_len = strlen(path); |
239 |
|
for (int i=0; e2t_translation[i].ext; i++) { |
240 |
|
int ext_len = strlen(e2t_translation[i].ext); |
249 |
|
} |
250 |
|
} |
251 |
|
|
252 |
< |
void set_finfo(const char *path, uint32 finfo, uint32 fxinfo) |
252 |
> |
void set_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir) |
253 |
|
{ |
254 |
|
// Open Finder info file |
255 |
|
int fd = open_finf(path, O_RDWR); |