MCPcopy Create free account
hub / github.com/NetHack/NetHack / copy_file

Function copy_file

outdated/sys/mac/macmain.c:142–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142static OSErr
143copy_file(short src_vol, long src_dir, short dst_vol, long dst_dir,
144 Str255 fName,
145 pascal OSErr (*opener)(short vRefNum, long dirID,
146 ConstStr255Param fileName,
147 signed char permission, short *refNum))
148{
149 short src_ref, dst_ref;
150 OSErr err = (*opener)(src_vol, src_dir, fName, fsRdPerm, &src_ref);
151 if (err == noErr) {
152 err = (*opener)(dst_vol, dst_dir, fName, fsWrPerm, &dst_ref);
153 if (err == noErr) {
154 long file_len;
155 err = GetEOF(src_ref, &file_len);
156 if (err == noErr) {
157 Handle buf;
158 long count = MaxBlock();
159 if (count > file_len)
160 count = file_len;
161
162 buf = NewHandle(count);
163 err = MemError();
164 if (err == noErr) {
165 while (count > 0) {
166 OSErr rd_err = FSRead(src_ref, &count, *buf);
167 err = FSWrite(dst_ref, &count, *buf);
168 if (err == noErr)
169 err = rd_err;
170 file_len -= count;
171 }
172 if (file_len == 0)
173 err = noErr;
174
175 DisposeHandle(buf);
176 }
177 }
178 FSClose(dst_ref);
179 }
180 FSClose(src_ref);
181 }
182
183 return err;
184}
185
186static void
187force_hdelete(short vol, long dir, Str255 fName)

Callers 1

process_openfileFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected