[Fedora-directory-devel] cleaning up FILE_PATHSEP?
Richard Megginson
rmeggins at redhat.com
Mon May 21 13:49:22 UTC 2007
Andrew Bartlett wrote:
> I recently began work on bug 239765, and came across the wonder of
> FILE_PATHSEP:
>
> #ifdef XP_UNIX
>
> #define FILE_PATHSEP '/'
> #define FILE_PATHSEPP "/"
> #define FILE_PARENT "../"
> #define WSACleanup()
>
> #elif defined(XP_WIN32)
>
> #define FILE_PATHSEP '/'
> #define FILE_PATHSEPP "\\\\"
> #define FILE_PARENT "..\\"
>
> #endif /* XP_WIN32 */
>
> Firstly, what little I knew about windows file handling told me that we
> could, at least on the supply side, use a unix /.
>
Yes. For modern versions of Windows. This may have been an artifact of
Win95/98/NT, or perhaps cases where these paths were passed to a command
interpreter (e.g. in a system() call).
> Indeed, I noted that much of create_instance does exactly that *and*
> passes in FILE_PATHSEP via %c. If we needed FILE_PATHSEP, then this
> would already be a problem:
>
> /* generate <confdir>/slapd-collations.conf */
> PR_snprintf(src, sizeof(src), "%s%c%s%c/config/%s-collations.conf",
> cf->sysconfdir, FILE_PATHSEP, cf->package_name,
> FILE_PATHSEP, PRODUCT_NAME);
> PR_snprintf(dest, sizeof(dest), "%s%c%s-collations.conf",
> cf->config_dir, FILE_PATHSEP, PRODUCT_NAME);
>
It probably doesn't matter anymore now that modern versions of Windows
support both \ and /.
> Even more priceless is the use of FILE_PATHSEP in
> ldap/admin/src/configure_instance.cpp:create_console_script(). (is
> there a /bin/sh that doesn't accept / as a path?).
>
Probably not anymore, if there ever was one that had a problem.
> Anyway, for my own amusement, I'll post a patch (probably untested on
> win32) to make this a little easier on the eyes, and perhaps even easier
> on new programmers to the codebase.
>
> Thoughts?
>
FILE_PATHSEP is used throughout fedora ds code . . .
> Andrew Bartlett
>
>
> ------------------------------------------------------------------------
>
> --
> Fedora-directory-devel mailing list
> Fedora-directory-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-directory-devel
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/fedora-directory-devel/attachments/20070521/ef5ac465/attachment.bin>
More information about the Fedora-directory-devel
mailing list