Ignore:
Timestamp:
Apr 5, 2009, 3:40:10 AM (10 years ago)
Author:
rme
Message:

Don't be too picky about pathnames/namestrings that the user provides
for :file and :directory. If they're invalid, the NSOpenPanel or
NSSavePanel will ignore them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/file-dialogs.lisp

    r11897 r11900  
    1010    (#/setAllowsMultipleSelection: open-panel #$NO)
    1111    (when directory
    12       (setq directory (#/autorelease (%make-nsstring (namestring directory)))))
     12      (setq directory (#/autorelease (%make-nsstring directory))))
    1313    (when file
    14       (setq file (#/autorelease (%make-nsstring (namestring file)))))
     14      (setq file (#/autorelease (%make-nsstring file))))
    1515    (when file-types
    1616      (setq types-array (make-instance 'ns:ns-mutable-array))
     
    3232       
    3333(defun cocoa-choose-file-dialog (&key directory file-types file button-string)
    34   (when (and directory (not (directoryp directory)))
    35     (error "~s doesn't designate a directory." directory))
     34  (when directory
     35    (setq directory (directory-namestring directory)))
    3636  (when file-types
    3737    (unless (and (listp file-types)
    3838                 (every #'stringp file-types))
    3939      (error "~s is not a list of strings." file-types)))
    40   (when (and file (not (probe-file file)))
    41     (error "~s doesn't designate a file." file))
     40  (when file
     41    (setq file (file-namestring file)))
     42  (check-type button-string (or null string))
    4243  (execute-in-gui #'(lambda () (%cocoa-choose-file-dialog directory file-types file button-string))))
    4344
     
    4849    (#/setCanSelectHiddenExtension: save-panel t)
    4950    (when directory
    50       (setq directory (#/autorelease (%make-nsstring (namestring directory)))))
     51      (setq directory (#/autorelease (%make-nsstring directory))))
    5152    (when file
    52       (setq file (#/autorelease (%make-nsstring (namestring file)))))
     53      (setq file (#/autorelease (%make-nsstring file))))
    5354    (when file-types
    5455      (setq types-array (make-instance 'ns:ns-mutable-array))
     
    6869
    6970(defun cocoa-choose-new-file-dialog (&key directory file-types file)
    70   (when (and directory (not (directoryp directory)))
    71     (error "~s doesn't designate a directory." directory))
     71  (when directory
     72    (setq directory (directory-namestring directory)))
     73  (when file
     74    (setq file (file-namestring file)))
    7275  (when file-types
    7376    (unless (and (listp file-types)
    7477                 (every #'stringp file-types))
    7578      (error "~s is not a list of strings." file-types)))
    76   (when (and file (not (probe-file file)))
    77     (error "~s doesn't designate a file." file))
    7879  (execute-in-gui #'(lambda () (%cocoa-choose-new-file-dialog directory file-types file))))
    7980
     
    9596    (#/setPrompt: open-panel #@"Choose")
    9697    (when directory
    97       (setq directory (#/autorelease (%make-nsstring (namestring directory)))))
     98      (setq directory (#/autorelease (%make-nsstring directory))))
    9899    (let  ((result (#/runModalForDirectory:file:types: open-panel directory
    99100                                                       nil nil)))
     
    107108
    108109(defun cocoa-choose-directory-dialog (&key directory)
    109   (when (and directory (not (directoryp directory)))
    110     (error "~s doesn't designate a directory." directory))
     110  (when directory
     111    (setq directory (directory-namestring directory)))
    111112  (execute-in-gui #'(lambda () (%cocoa-choose-directory-dialog directory))))
Note: See TracChangeset for help on using the changeset viewer.