Rev 193 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
259 | daniel-mar | 1 | /* |
2 | This file is part of a common library |
||
3 | Copyright (C) 1990-2009 Toby Thain, toby@telegraphics.com.au |
||
4 | |||
5 | This program is free software; you can redistribute it and/or modify |
||
6 | it under the terms of the GNU General Public License as published by |
||
7 | the Free Software Foundation; either version 2 of the License, or |
||
8 | (at your option) any later version. |
||
9 | |||
10 | This program is distributed in the hope that it will be useful, |
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
13 | GNU General Public License for more details. |
||
14 | |||
15 | You should have received a copy of the GNU General Public License |
||
16 | along with this program; if not, write to the Free Software |
||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
18 | */ |
||
19 | |||
20 | #include <files.h> |
||
21 | #include <gestalt.h> |
||
22 | |||
23 | #include "file_compat.h" |
||
24 | |||
25 | Boolean has_forks = false; |
||
26 | |||
27 | /* Check whether HFS+ calls are available (for large file support). */ |
||
28 | Boolean host_has_forks(){ |
||
29 | SInt32 resp; |
||
30 | |||
31 | return !Gestalt(gestaltFSAttr, &resp) && (resp & (1L<<gestaltFSSupportsHFSPlusVols)); |
||
32 | } |
||
33 | |||
34 | OSErr fspopendf_large(const FSSpec *spec, int perm, FILEREF *refNum){ |
||
35 | FSRef ref; |
||
36 | HFSUniStr255 dfname; |
||
37 | OSErr e; |
||
38 | |||
39 | if(has_forks){ |
||
40 | if( !(e = FSpMakeFSRef(spec,&ref)) && !(e = FSGetDataForkName(&dfname)) ) |
||
41 | e = FSOpenFork(&ref,dfname.length,dfname.unicode,perm,refNum); |
||
42 | }else |
||
43 | e = FSpOpenDF(spec,perm,refNum); |
||
44 | return e; |
||
45 | } |
||
46 | |||
47 | OSErr fsread_large(FILEREF refNum,FILECOUNT *count,void *buffPtr){ |
||
48 | OSErr e = has_forks ? FSReadFork(refNum,fsFromMark,0,*count,buffPtr,count) |
||
49 | : FSRead(refNum,count,buffPtr); |
||
50 | //if(e)DebugStr("\pfsread_large"); |
||
51 | return e; |
||
52 | } |
||
53 | |||
54 | OSErr fswrite_large(FILEREF refNum,FILECOUNT *count,void *buffPtr){ |
||
55 | OSErr e = has_forks ? FSWriteFork(refNum,fsFromMark,0,*count,buffPtr,count) |
||
56 | : FSWrite(refNum,count,buffPtr); |
||
57 | //if(e)DebugStr("\pfswrite_large"); |
||
58 | return e; |
||
59 | } |
||
60 | |||
61 | OSErr getfpos_large(FILEREF refNum,FILEPOS *filePos){ |
||
62 | OSErr e; |
||
63 | if(has_forks){ |
||
64 | e = FSGetForkPosition(refNum,filePos); |
||
65 | }else{ |
||
66 | long p; |
||
67 | e = GetFPos(refNum,&p); |
||
68 | if(!e) |
||
69 | *filePos = p; |
||
70 | } |
||
71 | //if(e)DebugStr("\pgetfpos_large"); |
||
72 | return e; |
||
73 | } |
||
74 | |||
75 | OSErr setfpos_large(FILEREF refNum,short posMode,FILEPOS posOff){ |
||
76 | OSErr e = has_forks ? FSSetForkPosition(refNum,posMode,posOff) |
||
77 | : SetFPos(refNum,posMode,posOff); |
||
78 | //if(e)DebugStr("\psetfpos_large"); |
||
79 | return e; |
||
80 | } |
||
81 | |||
82 | OSErr geteof_large(FILEREF refNum,FILEPOS *logEOF){ |
||
83 | OSErr e; |
||
84 | if(has_forks){ |
||
85 | e = FSGetForkSize(refNum,logEOF); |
||
86 | }else{ |
||
87 | FILEPOS p; |
||
88 | e = GetEOF(refNum,&p); |
||
89 | if(!e) |
||
90 | *logEOF = p; |
||
91 | } |
||
92 | //if(e)DebugStr("\pgeteof_large"); |
||
93 | return e; |
||
94 | } |
||
95 | |||
96 | /* |
||
97 | OSErr recoverfss(short refnum,FSSpec *fss){ |
||
98 | OSErr e; |
||
99 | FCBPBRec pb; |
||
100 | Str31 fname; |
||
101 | FSSpec fss; |
||
102 | FSRef ref; |
||
103 | HFSUniStr255 dfname; |
||
104 | |||
105 | pb.ioNamePtr = fname; |
||
106 | pb.ioVRefNum = 0; |
||
107 | pb.ioRefNum = refnum; |
||
108 | pb.ioFCBIndx = 0; |
||
109 | |||
110 | if(!(e = PBGetFCBInfoAsync(&pb)) ) |
||
111 | e = FSMakeFSSpec(pb.ioFCBVRefNum,pb.ioFCBParID,fname,fss); |
||
112 | |||
113 | return e; |
||
114 | } |
||
115 | OSErr reopenfork(short refnum,SInt8 perm,SInt16 *forkref){ |
||
116 | OSErr e; |
||
117 | FCBPBRec pb; |
||
118 | Str31 fname; |
||
119 | FSSpec fss; |
||
120 | FSRef ref; |
||
121 | HFSUniStr255 dfname; |
||
122 | |||
123 | pb.ioNamePtr = fname; |
||
124 | pb.ioVRefNum = 0; |
||
125 | pb.ioRefNum = refnum; |
||
126 | pb.ioFCBIndx = 0; |
||
127 | |||
128 | if(!(e = PBGetFCBInfoAsync(&pb)) |
||
129 | && !(e = FSMakeFSSpec(pb.ioFCBVRefNum,pb.ioFCBParID,fname,&fss)) |
||
130 | && !(e = FSpMakeFSRef(&fss,&ref)) |
||
131 | && !(e = FSGetDataForkName(&dfname)) ) |
||
132 | e = FSOpenFork(&ref,dfname.length,dfname.unicode,perm,forkref); |
||
133 | |||
134 | return e; |
||
135 | } |
||
136 | */ |