[Insight-developers] Bug in SystemTools due to ConvertToOutputPath on Windows?

Williams, Norman K norman-k-williams at uiowa.edu
Tue Dec 11 12:10:11 EST 2012


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