| 1 |
/* macnfile.c -- standard file operations for nifty application library |
| 2 |
*/ |
| 3 |
/* (C) Copyright 1995 by Carnegie Mellon University |
| 4 |
* All Rights Reserved. |
| 5 |
* |
| 6 |
* Permission to use, copy, modify, distribute, and sell this software |
| 7 |
* and its documentation for any purpose is hereby granted without |
| 8 |
* fee, provided that the above copyright notice appear in all copies |
| 9 |
* and that both that copyright notice and this permission notice |
| 10 |
* appear in supporting documentation, and that the name of Carnegie |
| 11 |
* Mellon University not be used in advertising or publicity |
| 12 |
* pertaining to distribution of the software without specific, |
| 13 |
* written prior permission. Carnegie Mellon University makes no |
| 14 |
* representations about the suitability of this software for any |
| 15 |
* purpose. It is provided "as is" without express or implied |
| 16 |
* warranty. |
| 17 |
* |
| 18 |
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO |
| 19 |
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 20 |
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE |
| 21 |
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 22 |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN |
| 23 |
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING |
| 24 |
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 25 |
* SOFTWARE. |
| 26 |
*/ |
| 27 |
/* (C) Copyright 1990-1995 by Christopher J. Newman |
| 28 |
* All Rights Reserved. |
| 29 |
* |
| 30 |
* Permission to use, copy, modify, distribute, and sell this software and its |
| 31 |
* documentation for any purpose is hereby granted without fee, provided that |
| 32 |
* the above copyright notice appear in all copies and that both that |
| 33 |
* copyright notice and this permission notice appear in supporting |
| 34 |
* documentation, and that the name of Christopher J. Newman not be used in |
| 35 |
* advertising or publicity pertaining to distribution of the software without |
| 36 |
* specific, written prior permission. Christopher J. Newman makes no |
| 37 |
* representations about the suitability of this software for any purpose. It |
| 38 |
* is provided "as is" without express or implied warranty. |
| 39 |
* |
| 40 |
* CHRISTOPHER J. NEWMAN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
| 41 |
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT |
| 42 |
* SHALL CHRISTOPHER J. NEWMAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
| 43 |
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
| 44 |
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 45 |
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
| 46 |
* OF THIS SOFTWARE. |
| 47 |
* |
| 48 |
* Author: Christopher J. Newman |
| 49 |
* Message: This is a nifty program. |
| 50 |
*/ |
| 51 |
|
| 52 |
#include <string.h> |
| 53 |
#include "macnapp.h" |
| 54 |
|
| 55 |
/* copy SFReply to StandardFileReply |
| 56 |
*/ |
| 57 |
static void sftostd(SFReply *rep, StandardFileReply *reply) |
| 58 |
{ |
| 59 |
long procid = 0; |
| 60 |
|
| 61 |
if ((reply->sfGood = rep->good) == true) { |
| 62 |
reply->sfReplacing = false; |
| 63 |
reply->sfType = rep->fType; |
| 64 |
memcpy((void *) reply->sfFile.name, rep->fName, *rep->fName + 1); |
| 65 |
reply->sfFile.parID = 0; |
| 66 |
reply->sfFile.vRefNum = rep->vRefNum; |
| 67 |
GetWDInfo(rep->vRefNum, &reply->sfFile.vRefNum, &reply->sfFile.parID, &procid); |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
/* get a file to save |
| 72 |
*/ |
| 73 |
void NAputFile(Str255 prompt, Str255 initfname, StandardFileReply *reply) |
| 74 |
{ |
| 75 |
SFReply rep; |
| 76 |
Point where; |
| 77 |
|
| 78 |
if (NAgestaltBits & NA_HASSTDFILE) { |
| 79 |
StandardPutFile(prompt, initfname, reply); |
| 80 |
} else { |
| 81 |
where.h = where.v = 0; |
| 82 |
SFPutFile(where, prompt, initfname, nil, &rep); |
| 83 |
sftostd(&rep, reply); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
/* get a file to open |
| 88 |
*/ |
| 89 |
void NAgetFile(FileFilterProcPtr filter, short numtypes, |
| 90 |
SFTypeList types, StandardFileReply *reply) |
| 91 |
{ |
| 92 |
Point p; |
| 93 |
SFReply rep; |
| 94 |
|
| 95 |
if (NAgestaltBits & NA_HASSTDFILE) { |
| 96 |
StandardGetFile(filter, numtypes, types, reply); |
| 97 |
} else { |
| 98 |
p.h = p.v = 0; |
| 99 |
SFGetFile(p, NULL, (ProcPtr) filter, numtypes, types, 0, &rep); |
| 100 |
sftostd(&rep, reply); |
| 101 |
} |
| 102 |
} |