Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-05-13 07:21:39 +0400
committerChristopher Faylor <me@cgf.cx>2005-05-13 07:21:39 +0400
commit66582dd6e7e63a2c179357e61fe2ccd53c83b02b (patch)
tree835a3aa965c077db8abf82eb3f2978bbfcc8e7d6 /winsup/cygwin/fhandler_netdrive.cc
parentcf55bf5ee88f0c91a9663d92dba3497c99c8d6fd (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/fhandler_netdrive.cc')
-rw-r--r--winsup/cygwin/fhandler_netdrive.cc20
1 files changed, 20 insertions, 0 deletions
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 <windows.h>
#include "winsup.h"
#include <unistd.h>
#include <stdlib.h>
@@ -19,12 +20,31 @@ details. */
#include "dtable.h"
#include "cygheap.h"
#include <assert.h>
+#include <shlwapi.h>
/* 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;
}