Gets the path of a special folder.
system
get-folder-path what &key create => result
| what⇩ |
A keyword. |
| create⇩ |
A boolean. |
| result⇩ |
A directory pathname naming the path, or nil. |
The function get-folder-path obtains the current value for various special folders often used by applications. It is useful because these paths may differ between versions of the operating system. get-folder-path is implemented all platforms, using system APIs on Microsoft Windows, macOS, iOS and Android.
On platforms other than Windows, macOS, iOS and Android it is a dummy function, which makes a path to a directory inside the user's home directory that looks like <homedir>/get-folder-path/<symbol-name-downcased>. This allows testing code that uses get-folder-path to work in the sense that files can be written and read from these directories.
what indicates the purpose of the special folder. For instance, :common-appdata means the folder containing application data for all users.
The following values of what are recognized on Microsoft Windows, macOS and iOS:
:appdata, :documents, :my-documents and :local-appdata.
:documents is an alias for :my-documents.
The following values of what are recognized on Microsoft Windows, macOS:
:common-appdata and :common-documents.
The following values are recognized on Microsoft Windows only: :program-files, :programs and :common-programs.
The following values are recognized on macOS and iOS only:
:my-library, :my-appsupport, :my-preferences, :my-caches and :my-logs.
The following values are recognized on macOS only:
:common-library, :common-appsupport, :common-preferences, :common-caches, :common-logs, :system-library.
On macOS and iOS, :appdata is an alias for :my-appsupport, :common-appdata is an alias for :common-appsupport, and :local-appdata is an alias for :common-appsupport.
If the folder does not exist and create is true, the folder is created. If the folder does not exist and create is false, result is nil. The default value of create is false.
The following values of what are recognized on Android:
:appdata, :local-appdata | |
|
Both of these return the same directory. It is the directory which is returned by the | |
:my-documents, :documents | |
|
On Android 4.4 and later this returns the "documents" directory in the "public external" directory (the result of calling Note: This is used as the home directory on Android, that is what cl:user-homedir-pathname returns. | |
:alarms, :dcim, :downloads, :movies, :music, :notifications, :pictures, :podcasts, :ringtones | |
|
Return the matching directory in the "public external" directory. This is the result of calling | |
:common-appdata |
Returns the external storage directory of the application if it is accessible, otherwise returns
Note that the application will need permission to access the external storage, by having uses-permission |
get-folder-path is implemented only on Windows and macOS.get-folder-path returns a string.
This form constructs a pathname to a file foo.lisp in the user's documents directory:
(make-pathname :name "foo" :type "lisp" :defaults (sys:get-folder-path :my-documents))
LispWorks® User Guide and Reference Manual - 18 Feb 2025 15:32:47