This section describes interfaces allowing you to identify and access various special locations in the file system.
This section describes the implementation of the Common Lisp function cl:user-homedir-pathname
.
On Unix-based systems, the home directory is looked up using the C function getpwuid
.
On Microsoft Windows systems, cl:user-homedir-pathname
uses the environment to construct its result. It uses the values of the environment variables HOMEDRIVE and HOMEPATH, if both are defined. If at least one of environment variables HOMEDRIVE and HOMEPATH is not defined, then a pathname #P"C:/users/
login-name"
is returned. These environment variables should be correctly set before LispWorks starts. However it is possible to change the values in Lisp using
(setf environment-variable)
On Android cl:user-homedir-pathname
returns the result of calling "android.os.Environment.getExternalStoragePublicDirectory"
with the value of android.os.Environment.DIRECTORY_DOCUMENTS
.
On Microsoft Windows, Mac OS X and Android there are various special folders used for application data and user data. Here are some examples of the folder for application data which is shared between all users.
Windows 10, Windows 8, Windows 7 and Windows Vista
C:\Documents and Settings\All Users.WINDOWS\Application Data
The result of calling getExternalFilesDir
on the application context with null
.
The locations and folder names can differ between versions of the operating system, therefore it is useful to have a system-independent way to get the path at run time. The function get-folder-path can be used to retrieve the path to special folders. Directory pathnames corresponding to each of the examples above can be obtained by calling:
(sys:get-folder-path :common-appdata)
Here is another example of differences between operating systems. On Windows 7 and Windows Vista:
(sys:get-folder-path :my-documents)
=>
#P"C:/Users/dubya/Documents/"
(sys:get-folder-path :my-documents)
=>
#P"/u/ldisk/dubya/Documents/"
See
get-folder-path
for more details.
On Microsoft Windows there is a profile folder for each user. You can find the profile path for the current user with the function
get-user-profile-directory
.
A "temp file" is a file in the "temp directory" which is guaranteed to be new. Its name contains a random element.
Create a temp file by calling either of the functions open-temp-file and create-temp-file. For example:
(create-temp-file :prefix "LW")
=>
#P"C:/DOCUME~1/dubya/LOCALS~1/Temp/LW383vwVfZN.tmp"
(create-temp-file :prefix "LW")
=>
#P"/tmp/LW1adokNa.tmp"
The function set-temp-directory allows you to set the "temp directory", that is the default directory used for temp files.
LispWorks User Guide and Reference Manual - 20 Sep 2017