From 66582dd6e7e63a2c179357e61fe2ccd53c83b02b Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Fri, 13 May 2005 03:21:39 +0000 Subject: * cygtls.cc (_cygtls::remove): Eliminate compiler warning. * dir.cc (mkdir): Check path for writability. (rmdir): Ditto. Remove check for special directories. * path.cc (path_conv::check): Set PATH_RO for virtual devices. Set error if read-only and asked for writability. * path.h (pathconv_arg): Add PC_WRITABLE. (path_types): Add PATH_RO. (path_conv::isro): Add (currently unused) check for read-only filesystem. Return "ENOSHARE" when we know a share doesn't exist. * include/sys/mount.h: Add MOUNT_RO flag. * autoload.cc (WNetGetResourceInformationA): Import. * fhandler_netdrive.cc (fhandler_netdrive::exists): Detect actual existence of remote system rather than always assuming that it exists. --- winsup/cygwin/fhandler_netdrive.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'winsup/cygwin/fhandler_netdrive.cc') diff --git a/winsup/cygwin/fhandler_netdrive.cc b/winsup/cygwin/fhandler_netdrive.cc index 82a4a49e0..0567a2fc3 100644 --- a/winsup/cygwin/fhandler_netdrive.cc +++ b/winsup/cygwin/fhandler_netdrive.cc @@ -8,6 +8,7 @@ This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ +#include #include "winsup.h" #include #include @@ -19,12 +20,31 @@ details. */ #include "dtable.h" #include "cygheap.h" #include +#include /* Returns 0 if path doesn't exist, >0 if path is a directory, -1 if path is a file, -2 if it's a symlink. */ int fhandler_netdrive::exists () { + char *to; + const char *from; + char namebuf[strlen (get_name ()) + 1]; + for (to = namebuf, from = get_name (); *from; to++, from++) + *to = (*from == '/') ? '\\' : *from; + *to = '\0'; + + NETRESOURCE nr = {0}; + nr.dwScope = RESOURCE_GLOBALNET; + nr.dwType = RESOURCETYPE_DISK; + nr.lpLocalName = NULL; + nr.lpRemoteName = namebuf; + LPTSTR sys = NULL; + char buf[8192]; + DWORD n = sizeof (buf); + DWORD rc = WNetGetResourceInformation (&nr, &buf, &n, &sys); + if (rc != ERROR_MORE_DATA && rc != NO_ERROR) + return 0; return 1; } -- cgit v1.2.3