[Insight-developers] Bug in SystemTools due to ConvertToOutputPath on Windows?
M.Staring at lumc.nl
M.Staring at lumc.nl
Tue Dec 11 14:15:44 EST 2012
Hi Kent,
Thanks for your feedback.
I (mis)used ConvertToOutputPath to make all the slashes in my path consistent, which was easier for some user of elastix to parse some log files. I just assumed that I could use the result of a kwsys function into any other kwsys function. This appears to not be the case, so either that is a bug or it may be useful to document so that other don't make the same mistake.
In the meantime I think I will unquote it and use the result. It is good to know that all Windows Compiler runtimes should be able to deal with that :-)
Regards, Marius
________________________________________
From: Williams, Norman K [norman-k-williams at uiowa.edu]
Sent: Tuesday, December 11, 2012 6:10 PM
To: Staring, M. (LKEB); insight-developers at itk.org
Subject: Re: [Insight-developers] Bug in SystemTools due to ConvertToOutputPath on Windows?
I'm confused by your use-case. ITK actually uses ConvertToOutputPath only
in 2 places -- itk::DCMTKSeriesFileNames and itk::TxtTransformIO.cxx --
and in both cases I suspect that they're probably not a very good idea.
Most, if not all Windows Compiler runtimes work just fine with Unix paths
-- forward slashes as path separators. And if you're calling any normal
I/O mechanism, you don't need to quote filenames with spaces in them, in
fact, as you found out, that is a bad idea.
The one place where you'd really need to use ConvertToOutputPath is when
you're building a command line, where the shell running the command line
needs strings with internal spaces need to be quoted.
The workaround is to call FileIsDirectory with the original path, before
calling ConvertToOutputPath.
Your suggestion is reasonable.
--
Kent Williams norman-k-williams at uiowa.edu
On 12/11/12 3:24 AM, "M.Staring at lumc.nl" <M.Staring at lumc.nl> wrote:
>Hi developers,
>
>Calling ConvertToOutputPath() on windows converts all slashes to windows
>slashes, and also double quotes the path when a space is present in it.
>The latter causes issues when feeding the corrected path name to
>functions such as FileIsDirectory() or JoinPath().
>
>For example I have the path: D:/tmp/New folder\
>I feed it to ConvertToOutputPath and get: "D:\tmp\New folder\"
>If I then call FileIsDirectory( path ), making sure that it exists, the
>function FileIsDirectory will check for the path
>FileIsDirectory()"D:\tmp\New folder\" which does not exist. However, the
>path D:\tmp\New folder\ (no quotes) does exist.
>
>Which leads me to conclude that on Windows the functions
>ConvertToOutputPath and FileIsDirectory are incompatible.
>There is also this issue with JoinPath() and possibly also with
>FileExists().
>
>I added a test program to demonstrate the behaviour, see attachment.
>
>I am not sure about the solution, but I guess JointPath and FileExists
>should unquote (if quotes are present) on windows before further
>processing. But maybe this was intended behaviour?
>
>Looking for some feedback, regards, Marius
>
>Marius Staring, PhD
>Division of Image Processing (LKEB)
>Department of Radiology
>Leiden University Medical Center
>PO Box 9600, 2300 RC Leiden, The Netherlands
>phone: +31 (0)71 526 2137, fax: +31 (0)71 524 8256
>m.staring at lumc.nl
>
>
________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, then delete it. Thank you.
________________________________
More information about the Insight-developers
mailing list