* environ.cc (dos_file_warning): Declare.

(parse_thing): Add "dosfilewarning".  Alphabetize.
* path.cc (normalize_posix_path): Return -1 when MS-DOS path detected.
(warn_msdos): New function.
(path_conv::check): Call if !PC_NOWARN and MS-DOS path detected.
(cygwin_conv_to_win32_path): Set PC_NOWARN when calling path_conv.
(cygwin_conv_to_full_win32_path): Ditto.
* path.h (pathconv_arg::PC_NOWARN): Define.
* shared_info.h (user_info::warned_msdos): New field.
(CURR_USER_MAGIC): Reset.
This commit is contained in:
Christopher Faylor
2006-08-01 18:00:44 +00:00
parent a121349405
commit 01bbb24d15
5 changed files with 55 additions and 10 deletions

View File

@@ -77,6 +77,7 @@ details. */
#include "cygtls.h"
#include <assert.h>
bool dos_file_warning = true;
static int normalize_win32_path (const char *, char *, char *&);
static void slashify (const char *, char *, int);
static void backslashify (const char *, char *, int);
@@ -208,8 +209,7 @@ pathmatch (const char *path1, const char *path2)
/* TODO: This function is used in mkdir and rmdir to generate correct
error messages in case of paths ending in /. or /.. components.
This test should eventually end up in path_conv::check in one way
or another. Right now, normalize_posix_path will just normalize
Right now, normalize_posix_path will just normalize
those components away, which changes the semantics. */
bool
has_dot_last_component (const char *dir)
@@ -322,7 +322,7 @@ win32_path:
if (!err)
for (char *p = dst; (p = strchr (p, '\\')); p++)
*p = '/';
return err;
return err ?: -1;
}
inline void
@@ -539,6 +539,26 @@ path_conv::get_nt_native_path (UNICODE_STRING &upath)
return &upath;
}
void
warn_msdos (const char *src)
{
if (user_shared->warned_msdos || !dos_file_warning)
return;
char posix_path[CYG_MAX_PATH];
small_printf ("cygwin warning:\n");
if (cygwin_conv_to_full_posix_path (src, posix_path))
small_printf (" MS-DOS style path detected: %s\n POSIX equivalent preferred.\n",
src);
else
small_printf (" MS-DOS style path detected: %s\n Preferred POSIX equivalent is: %s\n",
src, posix_path);
small_printf (" CYGWIN environment variable option \"nodosfilewarning\" turns off this warning.\n"
" Consult the user's guide for more details about POSIX paths:\n"
" http://cygwin.com/cygwin-ug-net/using.html#using-pathnames\n");
user_shared->warned_msdos = true;
}
/* Convert an arbitrary path SRC to a pure Win32 path, suitable for
passing to Win32 API routines.
@@ -602,6 +622,7 @@ path_conv::check (const char *src, unsigned opt,
return;
}
bool is_msdos = false;
/* This loop handles symlink expansion. */
for (;;)
{
@@ -610,8 +631,14 @@ path_conv::check (const char *src, unsigned opt,
is_relpath = !isabspath (src);
error = normalize_posix_path (src, path_copy, tail);
if (error)
if (error > 0)
return;
if (error < 0)
{
if (component == 0)
is_msdos = true;
error = 0;
}
/* Detect if the user was looking for a directory. We have to strip the
trailing slash initially while trying to add extensions but take it
@@ -1059,6 +1086,8 @@ out:
if (tail < path_end && tail > path_copy + 1)
*tail = '/';
set_normalized_path (path_copy, strip_tail);
if (is_msdos && !(opt & PC_NOWARN))
warn_msdos (src);
}
#if 0
@@ -3646,7 +3675,7 @@ fchdir (int fd)
extern "C" int
cygwin_conv_to_win32_path (const char *path, char *win32_path)
{
path_conv p (path, PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOFULL);
path_conv p (path, PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOFULL | PC_NOWARN);
if (p.error)
{
win32_path[0] = '\0';
@@ -3662,7 +3691,7 @@ cygwin_conv_to_win32_path (const char *path, char *win32_path)
extern "C" int
cygwin_conv_to_full_win32_path (const char *path, char *win32_path)
{
path_conv p (path, PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK);
path_conv p (path, PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOWARN);
if (p.error)
{
win32_path[0] = '\0';