ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/extfs_unix.cpp
Revision: 1.1
Committed: 1999-10-19T17:41:34Z (25 years, 1 month ago) by cebix
Branch: MAIN
Log Message:
- added external file system
- moved most init/deinit code to InitAll()/ExitAll() in main.cpp

File Contents

# User Rev Content
1 cebix 1.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     * Get/set finder type/creator for file specified by full path
61     */
62    
63     struct ext2type {
64     const char *ext;
65     uint32 type;
66     uint32 creator;
67     };
68    
69     static const ext2type e2t_translation[] = {
70     {".z", 'ZIVM', 'LZIV'},
71     {".gz", 'Gzip', 'Gzip'},
72     {".hqx", 'TEXT', 'SITx'},
73     {".pdf", 'PDF ', 'CARO'},
74     {".ps", 'TEXT', 'ttxt'},
75     {".sit", 'SIT!', 'SITx'},
76     {".tar", 'TARF', 'TAR '},
77     {".uu", 'TEXT', 'SITx'},
78     {".uue", 'TEXT', 'SITx'},
79     {".zip", 'ZIP ', 'ZIP '},
80     {".8svx", '8SVX', 'SNDM'},
81     {".aifc", 'AIFC', 'TVOD'},
82     {".aiff", 'AIFF', 'TVOD'},
83     {".au", 'ULAW', 'TVOD'},
84     {".mid", 'MIDI', 'TVOD'},
85     {".midi", 'MIDI', 'TVOD'},
86     {".mp2", 'MPG ', 'TVOD'},
87     {".mp3", 'MPG ', 'TVOD'},
88     {".wav", 'WAVE', 'TVOD'},
89     {".bmp", 'BMPf', 'ogle'},
90     {".gif", 'GIFf', 'ogle'},
91     {".lbm", 'ILBM', 'GKON'},
92     {".ilbm", 'ILBM', 'GKON'},
93     {".jpg", 'JPEG', 'ogle'},
94     {".jpeg", 'JPEG', 'ogle'},
95     {".pict", 'PICT', 'ogle'},
96     {".png", 'PNGf', 'ogle'},
97     {".sgi", '.SGI', 'ogle'},
98     {".tga", 'TPIC', 'ogle'},
99     {".tif", 'TIFF', 'ogle'},
100     {".tiff", 'TIFF', 'ogle'},
101     {".html", 'TEXT', 'MOSS'},
102     {".txt", 'TEXT', 'ttxt'},
103     {".rtf", 'TEXT', 'MSWD'},
104     {".c", 'TEXT', 'R*ch'},
105     {".cc", 'TEXT', 'R*ch'},
106     {".cpp", 'TEXT', 'R*ch'},
107     {".cxx", 'TEXT', 'R*ch'},
108     {".h", 'TEXT', 'R*ch'},
109     {".hh", 'TEXT', 'R*ch'},
110     {".hpp", 'TEXT', 'R*ch'},
111     {".hxx", 'TEXT', 'R*ch'},
112     {".s", 'TEXT', 'R*ch'},
113     {".i", 'TEXT', 'R*ch'},
114     {".mpg", 'MPEG', 'TVOD'},
115     {".mpeg", 'MPEG', 'TVOD'},
116     {".mov", 'MooV', 'TVOD'},
117     {".fli", 'FLI ', 'TVOD'},
118     {".avi", 'VfW ', 'TVOD'},
119     {NULL, 0, 0} // End marker
120     };
121    
122     void get_finder_type(const char *path, uint32 &type, uint32 &creator)
123     {
124     type = 0;
125     creator = 0;
126    
127     // Translate file name extension to MacOS type/creator
128     int path_len = strlen(path);
129     for (int i=0; e2t_translation[i].ext; i++) {
130     int ext_len = strlen(e2t_translation[i].ext);
131     if (path_len < ext_len)
132     continue;
133     if (!strcmp(path + path_len - ext_len, e2t_translation[i].ext)) {
134     type = e2t_translation[i].type;
135     creator = e2t_translation[i].creator;
136     break;
137     }
138     }
139     }
140    
141     void set_finder_type(const char *path, uint32 type, uint32 creator)
142     {
143     }
144    
145    
146     /*
147     * Get/set finder flags for file/dir specified by full path (MACOS:HFS_FLAGS attribute)
148     */
149    
150     void get_finder_flags(const char *path, uint16 &flags)
151     {
152     flags = DEFAULT_FINDER_FLAGS; // Default
153     }
154    
155     void set_finder_flags(const char *path, uint16 flags)
156     {
157     }
158    
159    
160     /*
161     * Resource fork emulation functions
162     */
163    
164     uint32 get_rfork_size(const char *path)
165     {
166     return 0;
167     }
168    
169     int open_rfork(const char *path, int flag)
170     {
171     return -1;
172     }
173    
174     void close_rfork(const char *path, int fd)
175     {
176     }
177    
178    
179     /*
180     * Read "length" bytes from file to "buffer",
181     * returns number of bytes read (or 0)
182     */
183    
184     size_t extfs_read(int fd, void *buffer, size_t length)
185     {
186     errno = 0;
187     return read(fd, buffer, length);
188     }
189    
190    
191     /*
192     * Write "length" bytes from "buffer" to file,
193     * returns number of bytes written (or 0)
194     */
195    
196     size_t extfs_write(int fd, void *buffer, size_t length)
197     {
198     errno = 0;
199     return write(fd, buffer, length);
200     }