* 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.
This commit is contained in:
Christopher Faylor
2005-05-13 03:21:39 +00:00
parent cf55bf5ee8
commit 66582dd6e7
8 changed files with 72 additions and 26 deletions

View File

@@ -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;
}