diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/macfns.c | 69 |
1 files changed, 28 insertions, 41 deletions
diff --git a/src/macfns.c b/src/macfns.c index 99abc643043..4ede8b7971b 100644 --- a/src/macfns.c +++ b/src/macfns.c | |||
| @@ -4226,21 +4226,13 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) | |||
| 4226 | /* Set the default location and continue*/ | 4226 | /* Set the default location and continue*/ |
| 4227 | if (status == noErr) | 4227 | if (status == noErr) |
| 4228 | { | 4228 | { |
| 4229 | Lisp_Object encoded_dir = ENCODE_FILE (dir); | ||
| 4229 | AEDesc defLocAed; | 4230 | AEDesc defLocAed; |
| 4230 | #ifdef MAC_OSX | 4231 | |
| 4231 | FSRef defLoc; | 4232 | status = AECreateDesc (TYPE_FILE_NAME, SDATA (encoded_dir), |
| 4232 | status = FSPathMakeRef(SDATA(ENCODE_FILE(dir)), &defLoc, NULL); | 4233 | SBYTES (encoded_dir), &defLocAed); |
| 4233 | #else | ||
| 4234 | FSSpec defLoc; | ||
| 4235 | status = posix_pathname_to_fsspec (SDATA (ENCODE_FILE (dir)), &defLoc); | ||
| 4236 | #endif | ||
| 4237 | if (status == noErr) | 4234 | if (status == noErr) |
| 4238 | { | 4235 | { |
| 4239 | #ifdef MAC_OSX | ||
| 4240 | AECreateDesc(typeFSRef, &defLoc, sizeof(FSRef), &defLocAed); | ||
| 4241 | #else | ||
| 4242 | AECreateDesc(typeFSS, &defLoc, sizeof(FSSpec), &defLocAed); | ||
| 4243 | #endif | ||
| 4244 | NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed); | 4236 | NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed); |
| 4245 | AEDisposeDesc(&defLocAed); | 4237 | AEDisposeDesc(&defLocAed); |
| 4246 | } | 4238 | } |
| @@ -4262,41 +4254,36 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) | |||
| 4262 | case kNavUserActionSaveAs: | 4254 | case kNavUserActionSaveAs: |
| 4263 | { | 4255 | { |
| 4264 | NavReplyRecord reply; | 4256 | NavReplyRecord reply; |
| 4265 | AEDesc aed; | 4257 | Size len; |
| 4266 | #ifdef MAC_OSX | ||
| 4267 | FSRef fsRef; | ||
| 4268 | #else | ||
| 4269 | FSSpec fs; | ||
| 4270 | #endif | ||
| 4271 | status = NavDialogGetReply(dialogRef, &reply); | ||
| 4272 | 4258 | ||
| 4273 | #ifdef MAC_OSX | 4259 | status = NavDialogGetReply(dialogRef, &reply); |
| 4274 | AECoerceDesc(&reply.selection, typeFSRef, &aed); | 4260 | if (status != noErr) |
| 4275 | AEGetDescData(&aed, (void *) &fsRef, sizeof (FSRef)); | 4261 | break; |
| 4276 | FSRefMakePath(&fsRef, (UInt8 *) filename, sizeof (filename)); | 4262 | status = AEGetNthPtr (&reply.selection, 1, TYPE_FILE_NAME, |
| 4277 | #else | 4263 | NULL, NULL, filename, |
| 4278 | AECoerceDesc (&reply.selection, typeFSS, &aed); | 4264 | sizeof (filename) - 1, &len); |
| 4279 | AEGetDescData (&aed, (void *) &fs, sizeof (FSSpec)); | 4265 | if (status == noErr) |
| 4280 | fsspec_to_posix_pathname (&fs, filename, sizeof (filename) - 1); | ||
| 4281 | #endif | ||
| 4282 | AEDisposeDesc(&aed); | ||
| 4283 | if (reply.saveFileName) | ||
| 4284 | { | 4266 | { |
| 4285 | /* If it was a saved file, we need to add the file name */ | 4267 | len = min (len, sizeof (filename) - 1); |
| 4286 | int len = strlen(filename); | 4268 | filename[len] = '\0'; |
| 4287 | if (len && filename[len-1] != '/') | 4269 | if (reply.saveFileName) |
| 4288 | filename[len++] = '/'; | 4270 | { |
| 4289 | CFStringGetCString(reply.saveFileName, filename+len, | 4271 | /* If it was a saved file, we need to add the file name */ |
| 4290 | sizeof (filename) - len, | 4272 | if (len && len < sizeof (filename) - 1 |
| 4273 | && filename[len-1] != '/') | ||
| 4274 | filename[len++] = '/'; | ||
| 4275 | CFStringGetCString(reply.saveFileName, filename+len, | ||
| 4276 | sizeof (filename) - len, | ||
| 4291 | #if MAC_OSX | 4277 | #if MAC_OSX |
| 4292 | kCFStringEncodingUTF8 | 4278 | kCFStringEncodingUTF8 |
| 4293 | #else | 4279 | #else |
| 4294 | CFStringGetSystemEncoding () | 4280 | CFStringGetSystemEncoding () |
| 4295 | #endif | 4281 | #endif |
| 4296 | ); | 4282 | ); |
| 4283 | } | ||
| 4284 | file = DECODE_FILE (make_unibyte_string (filename, | ||
| 4285 | strlen (filename))); | ||
| 4297 | } | 4286 | } |
| 4298 | file = DECODE_FILE (make_unibyte_string (filename, | ||
| 4299 | strlen (filename))); | ||
| 4300 | NavDisposeReply(&reply); | 4287 | NavDisposeReply(&reply); |
| 4301 | } | 4288 | } |
| 4302 | break; | 4289 | break; |