Ahankhah Posted September 6, 2010 Posted September 6, 2010 Hi, when I use vl-file-directory-p function to reports me about existence of some files and directories, it returns nil for names including non-English characters. Attached is a file with a Persian name: (لاله ها.jpg). I placed the file in "c:\". When I issue the function, it returns nil. (vl-file-directory-p "c:\\لاله ها.jpg") Should any one say me what I can do? Thanks in advance Mehrdad Ahankhah www.irancad.com Quote
Lee Mac Posted September 6, 2010 Posted September 6, 2010 vl-file-directory-p checks the existence of a directory, not a file, be sure to read the help file on this function. The function you should use is perhaps findfile. Hint: when programming, always assume you (the programmer) is wrong, don't blame the tools. Quote
Ahankhah Posted September 7, 2010 Author Posted September 7, 2010 Lee Mac, you are right. My mistakes was due to my abstraction of the following code. Indeed in this function, I return the correct type of the arg string. (defun MT-?-Which-File-Or-Folder (arg / ret) (cond ((not (findfile arg)) (setq ret nil)) ((vl-file-directory-p arg) (setq ret 'Folder)) (T (setq ret 'File)) ) ret ) It returns 'File, 'Folder, or nil. In this example it returns nil, which means that the built in visual lisp functions makes a mistake. Should you try the function with any existing file or folder, and see the bug about my file: "لاله ها.jpg" Mehrdad Ahankhah مهرداد آهن خواه http://www.irancad.com Quote
Ahankhah Posted September 7, 2010 Author Posted September 7, 2010 (edited) I found the solution, thanks to McNeel for distributing DOSLIB. To go to download page click here. (dos_dirp path) (dos_filep filename) Edited September 7, 2010 by Ahankhah Quote
BlackBox Posted September 7, 2010 Posted September 7, 2010 :: As this thread is being duplicated in another forum, for clarification :: I too cannot get the vl-file-directory-p function to work, my friend... Perhaps this is the result of a 'language' issue..? The VLIDE displays only question marks (\\??? ??") for the directory name, whereas AutoCAD shows the correct characters. However, that is why Lee Mac gave you a working solution... to use the findfile function instead. Here are my results, using Lee's solution, for you to verify: Command: (findfile "c:\\Documents and Settings\\[color=red]UserName[/color]\\Desktop\\لاله ها") "C:\\Documents and Settings\\[color=#ff0000]UserName[/color]\\Desktop\\لاله ها" If you choose to use DOSLib, that is your choice, but the findfile function (as Lee originally suggested) does in fact work. Hope this helps! Quote
Lee Mac Posted September 7, 2010 Posted September 7, 2010 Cheers mate for the reference, and I like your sig on augi, true blood is awesome. Quote
BlackBox Posted September 7, 2010 Posted September 7, 2010 Cheers mate for the reference, and I like your sig on augi, true blood is awesome. You're welcome. We may have a pond between us, but if/when I hop to your side for holiday, pints are on me! What *beith the problem* with userbars here ...? Is it that I just have yet to 'earn' the privilege (like having a custom Avatar pic as a junior member)...? Quote
Lee Mac Posted September 7, 2010 Posted September 7, 2010 We may have a pond between us, but if/when I hop to your side for holiday, pints are on me! Sounds good mate. What *beith the problem* with userbars here ...? Is it that I just have yet to 'earn' the privilege (like having a custom Avatar pic as a junior member)...? Nah - I don't think GIFs are allowed in sigs full-stop here, otherwise I think users may get a bit OTT with what they use and it just makes the Mods jobs harder I suppose. Quote
Ahankhah Posted September 8, 2010 Author Posted September 8, 2010 :: As this thread is being duplicated in another forum, for clarification :: RenderMan, findfile shows that the folder or file exists, but after knowing that my program wants to get files and sub-folders inside the "لاله ها" folder. As you can see, vl-directory-files (it is not vl-file-directory-p) doesn't work correctly: (vl-directory-files "c:\\Documents and Settings\\[u][color=darkorchid]RenderMan&LeeMacSig[/color][/u]\\Desktop\\لاله ها"[i] nil 0[/i]) Anyway, DOSLib helped me in all accesses to files and folders utilities. I offer DOSLib to every one who doesn't want to use C language and ARX. Mehrdad Ahankhah www.irancad.com Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.