ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/extfs_unix.cpp
Revision: 1.2
Committed: 1999-10-20T17:23:56Z (25 years, 1 month ago) by cebix
Branch: MAIN
CVS Tags: snapshot-21101999
Changes since 1.1: +3 -1 lines
Log Message:
- fixed bugs in extfs.cpp:
   - root's parent now has an FSItem, so finding the volume by name with
     parent dirID 1 now works
   - fs_get_file_info() and fs_get_cat_info() handle all negative values of
     dir_index correctly
   - fs_set_fpos() handles fsFromLEOF positioning mode
   - replaced "%#s" format codes in debug output
- fixed some file extensions in extfs_unix.cpp
- "speaker" means "main volume", as before

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 cebix 1.2 {".Z", 'ZIVM', 'LZIV'},
71 cebix 1.1 {".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 cebix 1.2 {".C", 'TEXT', 'R*ch'},
106 cebix 1.1 {".cc", 'TEXT', 'R*ch'},
107     {".cpp", 'TEXT', 'R*ch'},
108     {".cxx", 'TEXT', 'R*ch'},
109     {".h", 'TEXT', 'R*ch'},
110     {".hh", 'TEXT', 'R*ch'},
111     {".hpp", 'TEXT', 'R*ch'},
112     {".hxx", 'TEXT', 'R*ch'},
113     {".s", 'TEXT', 'R*ch'},
114 cebix 1.2 {".S", 'TEXT', 'R*ch'},
115 cebix 1.1 {".i", 'TEXT', 'R*ch'},
116     {".mpg", 'MPEG', 'TVOD'},
117     {".mpeg", 'MPEG', 'TVOD'},
118     {".mov", 'MooV', 'TVOD'},
119     {".fli", 'FLI ', 'TVOD'},
120     {".avi", 'VfW ', 'TVOD'},
121     {NULL, 0, 0} // End marker
122     };
123    
124     void get_finder_type(const char *path, uint32 &type, uint32 &creator)
125     {
126     type = 0;
127     creator = 0;
128    
129     // Translate file name extension to MacOS type/creator
130     int path_len = strlen(path);
131     for (int i=0; e2t_translation[i].ext; i++) {
132     int ext_len = strlen(e2t_translation[i].ext);
133     if (path_len < ext_len)
134     continue;
135     if (!strcmp(path + path_len - ext_len, e2t_translation[i].ext)) {
136     type = e2t_translation[i].type;
137     creator = e2t_translation[i].creator;
138     break;
139     }
140     }
141     }
142    
143     void set_finder_type(const char *path, uint32 type, uint32 creator)
144     {
145     }
146    
147    
148     /*
149     * Get/set finder flags for file/dir specified by full path (MACOS:HFS_FLAGS attribute)
150     */
151    
152     void get_finder_flags(const char *path, uint16 &flags)
153     {
154     flags = DEFAULT_FINDER_FLAGS; // Default
155     }
156    
157     void set_finder_flags(const char *path, uint16 flags)
158     {
159     }
160    
161    
162     /*
163     * Resource fork emulation functions
164     */
165    
166     uint32 get_rfork_size(const char *path)
167     {
168     return 0;
169     }
170    
171     int open_rfork(const char *path, int flag)
172     {
173     return -1;
174     }
175    
176     void close_rfork(const char *path, int fd)
177     {
178     }
179    
180    
181     /*
182     * Read "length" bytes from file to "buffer",
183     * returns number of bytes read (or 0)
184     */
185    
186     size_t extfs_read(int fd, void *buffer, size_t length)
187     {
188     errno = 0;
189     return read(fd, buffer, length);
190     }
191    
192    
193     /*
194     * Write "length" bytes from "buffer" to file,
195     * returns number of bytes written (or 0)
196     */
197    
198     size_t extfs_write(int fd, void *buffer, size_t length)
199     {
200     errno = 0;
201     return write(fd, buffer, length);
202     }