* dtable.cc (dtable::build_fhandler_from_name): Just pass posix path along to
set_name via return_and_clear_normalized_path. (dtable::build_fhandler): New method with const char * argument. (dtable::reset_unix_path_name): Eliminate. (dtable::dup_worker): Use correct build_fhandler method. * mmap.cc (mmap_record::alloc_fh): Ditto. * dtable.h (dtable::build_fhandler): New method. (dtable::reset_unix_path_name): Eliminate. * fhandler.cc (fhandler_base::set_name): Assume that unix_name has already been cmalloced. (fhandler_base::reset_unix_path_name): Eliminate. (fhandler_base::~fhandler_base): Coercion for cfree. * fhandler.h (fhandler_base::unix_path_name): Make const char *. (fhandler_base::win32_path_name): Ditto. (fhandler_base::reset_unix_path_name): Eliminate. * fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Accommodate const char *ness of win32_path_name. * fhandler_socket.cc (fhandler_socket::fstat): Accommodate new set_name requirements. * path.cc (path_conv::return_and_clear_normalized_path): New method. (path_conv::clear_normalized_path): Eliminate. (path_conv::~path_conv): Ditto. (path_conv::check): Accommodate new build_fhandler method. * path.h (path_conv::~path_conv): Eliminate. (path_conv::clear_normalized_path): Ditto. (path_conv::return_and_clear_normalized_path): Declare new method.
This commit is contained in:
@ -161,8 +161,9 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
|
||||
else
|
||||
{
|
||||
const char *fmt = get_native_name ();
|
||||
win32_path_name = (char *) cmalloc (HEAP_STR, strlen(fmt) + 16);
|
||||
__small_sprintf (win32_path_name, fmt, unit);
|
||||
char *w = (char *) cmalloc (HEAP_STR, strlen(fmt) + 16);
|
||||
__small_sprintf (w, fmt, unit);
|
||||
win32_path_name = w;
|
||||
}
|
||||
|
||||
if (win32_path_name == NULL)
|
||||
@ -178,12 +179,15 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
|
||||
path_conv. Ideally, we should pass in a format string and build the
|
||||
unix_path, too. */
|
||||
if (!is_device () || *win32_path_name != '\\')
|
||||
unix_path_name = cstrdup (unix_path);
|
||||
unix_path_name = unix_path;
|
||||
else
|
||||
{
|
||||
unix_path_name = cstrdup (win32_path_name);
|
||||
for (char *p = unix_path_name; (p = strchr (p, '\\')); p++)
|
||||
*p = '/';
|
||||
char *p = cstrdup (win32_path_name);
|
||||
unix_path_name = p;
|
||||
while ((p = strchr (p, '\\')) != NULL)
|
||||
*p++ = '/';
|
||||
if (unix_path)
|
||||
cfree ((void *) unix_path);
|
||||
}
|
||||
|
||||
if (unix_path_name == NULL)
|
||||
@ -194,13 +198,6 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
|
||||
namehash = hash_path_name (0, win32_path_name);
|
||||
}
|
||||
|
||||
void
|
||||
fhandler_base::reset_unix_path_name (const char *unix_path)
|
||||
{
|
||||
cfree (unix_path_name);
|
||||
unix_path_name = cstrdup (unix_path);
|
||||
}
|
||||
|
||||
/* Detect if we are sitting at EOF for conditions where Windows
|
||||
returns an error but UNIX doesn't. */
|
||||
static int __stdcall
|
||||
@ -1047,9 +1044,9 @@ fhandler_base::fhandler_base (DWORD devtype, int unit):
|
||||
fhandler_base::~fhandler_base (void)
|
||||
{
|
||||
if (unix_path_name != NULL)
|
||||
cfree (unix_path_name);
|
||||
cfree ((void *) unix_path_name);
|
||||
if (win32_path_name != NULL)
|
||||
cfree (win32_path_name);
|
||||
cfree ((void *) win32_path_name);
|
||||
if (rabuf)
|
||||
free (rabuf);
|
||||
unix_path_name = win32_path_name = NULL;
|
||||
|
Reference in New Issue
Block a user