| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hello, I was wondering whats the recommended way of changing a file type in lisp. Here is what I tried: [1]> (setf x (pathname "/home/noob/tmp.txt")) #P"/home/noob/tmp.txt" [2]> x #P"/home/noob/tmp.txt" [3]> (setf (pathname-type x) "doc") *** - FUNCTION: undefined function (SETF PATHNAME-TYPE) The following restarts are available: USE-VALUE :R1 You may input a value to be used instead of (FDEFINITION '(SETF PATHNAME-TYPE)). RETRY :R2 Retry STORE-VALUE :R3 You may input a new value for (FDEFINITION '(SETF PATHNAME-TYPE)). ABORT :R4 ABORT I tried the above in sbcl as well as clisp. I get the same error. Is 'pathname-type' not setf-able? This seems to work but I am quite new to lisp and was wondering if this is the correct way to do it. Break 1 [4]> (setf x (make-pathname :defaults x :type "doc")) #P"/home/noob/tmp.doc" Break 1 [4]> x #P"/home/noob/tmp.doc" Break 1 [4]> Thanks very much. Parth |
|
#2
| |||
| |||
| parth.malwankar@gmail.com writes: > Hello, > > I was wondering whats the recommended way of changing a file > type in lisp. (rename-file path (make-pathname :type new-type)) Note however that you cannot _remove_ the type of a file with CL. You could end up with a physical file name such as: "toto." but not "toto". > Here is what I tried: > > [1]> (setf x (pathname "/home/noob/tmp.txt")) > #P"/home/noob/tmp.txt" > [2]> x > #P"/home/noob/tmp.txt" > [3]> (setf (pathname-type x) "doc") > > *** - FUNCTION: undefined function (SETF PATHNAME-TYPE) > The following restarts are available: > USE-VALUE :R1 > You may input a value to be used instead of (FDEFINITION > '(SETF PATHNAME-TYPE)). > RETRY :R2 Retry > STORE-VALUE :R3 You may input a new value for (FDEFINITION > '(SETF PATHNAME-TYPE)). > ABORT :R4 ABORT > > I tried the above in sbcl as well as clisp. I get the same > error. Is 'pathname-type' not setf-able? CLHS says: Function PATHNAME-HOST, PATHNAME-DEVICE, PATHNAME-DIRECTORY, PATHNAME-NAME, PATHNAME-TYPE, PATHNAME-VERSION ^^^^^^^^ not Accessor, so no, pathname-type may not be setf-able. > This seems to work but I am quite new to lisp and was wondering if > this is the correct way to do it. > > Break 1 [4]> (setf x (make-pathname :defaults x :type "doc")) > #P"/home/noob/tmp.doc" > Break 1 [4]> x > #P"/home/noob/tmp.doc" > Break 1 [4]> Yes, that's the best way to do it. -- __Pascal Bourguignon__ http://www.informatimago.com/ The rule for today: Touch my tail, I shred your hand. New rule tomorrow. |
|
#3
| |||
| |||
| On Jun 17, 11:01 pm, p...@informatimago.com (Pascal J. Bourguignon) wrote: > parth.malwan...@gmail.com writes: > > Hello, > > > I was wondering whats the recommended way of changing a file > > type in lisp. > > (rename-file path (make-pathname :type new-type)) > > Note however that you cannot _remove_ the type of a file with CL. You > could end up with a physical file name such as: "toto." but not "toto". > > > > > Here is what I tried: > > > [1]> (setf x (pathname "/home/noob/tmp.txt")) > > #P"/home/noob/tmp.txt" > > [2]> x > > #P"/home/noob/tmp.txt" > > [3]> (setf (pathname-type x) "doc") > > > *** - FUNCTION: undefined function (SETF PATHNAME-TYPE) > > The following restarts are available: > > USE-VALUE :R1 > > You may input a value to be used instead of (FDEFINITION > > '(SETF PATHNAME-TYPE)). > > RETRY :R2 Retry > > STORE-VALUE :R3 You may input a new value for (FDEFINITION > > '(SETF PATHNAME-TYPE)). > > ABORT :R4 ABORT > > > I tried the above in sbcl as well as clisp. I get the same > > error. Is 'pathname-type' not setf-able? > > CLHS says: > Function PATHNAME-HOST, PATHNAME-DEVICE, PATHNAME-DIRECTORY, PATHNAME-NAME, PATHNAME-TYPE, PATHNAME-VERSION > ^^^^^^^^ > not Accessor, so no, pathname-type may not be setf-able. > Thanks Pascal. Wasn't aware of this detail .. this should certainly make life easier ![]() > > This seems to work but I am quite new to lisp and was wondering if > > this is the correct way to do it. > > > Break 1 [4]> (setf x (make-pathname :defaults x :type "doc")) > > #P"/home/noob/tmp.doc" > > Break 1 [4]> x > > #P"/home/noob/tmp.doc" > > Break 1 [4]> > > Yes, that's the best way to do it. > > -- > __Pascal Bourguignon__ http://www.informatimago.com/ > The rule for today: > Touch my tail, I shred your hand. > New rule tomorrow. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.