ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is it possible to re-cast a variable type to another? I'm trying to cast the returned value of GET-UNIVERSAL-TIME to a string.
I am also trying to use CONCATENATE to...well...concatenate two pathnames, but I can't remember what the type is that I need to specify; 'STRING signals an error, and 'PATH or 'PATHNAME don't exist. I've already tried looking this up, and there doesn't seem to be any PATHNAME or PATH type or subtype.
Here's an example:
Code:
(defparameter *current-log-file* nil)
(setq *current-log-file*
(make-pathname
:directory '(:absolute "etc" "pkgsd" "logs")
:name (get-universal-time) ; This is one of the offending lines
:type "txt"))
...
(defparameter *base-dir* #p"/etc/pkgsd")
(defparameter *temp-dir* #p"/tmp")
; This is the other offending line
(defparameter *temp-path* (concatenate 'string *base-dir* *temp-dir*))
Should I perhaps just leave the two directory parameters as strings and work with them thusly?
The first error results from GET-UNIVERSAL-TIME which returns an integer. To get this into a string, you can use WRITE-TO-STRING. The latter problem is because pathnames aren't sequences and thus can't be concatenated. But you can convert the pathnames into strings, then concatenate them, and convert them back into a pathname again. Here's some code:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.