summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_disk_file.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2009-08-04 04:20:36 +0000
committerChristopher Faylor <me@cgf.cx>2009-08-04 04:20:36 +0000
commit824d851859450e8c3943d0439fc57a3520081eb4 (patch)
treef6ac160a57aee5c0875ba90309fba2ce6337158c /winsup/cygwin/fhandler_disk_file.cc
parentff7b364c121175ad1b5b88ec4010ee81dab1e5c4 (diff)
downloadcygnal-824d851859450e8c3943d0439fc57a3520081eb4.tar.gz
cygnal-824d851859450e8c3943d0439fc57a3520081eb4.tar.bz2
cygnal-824d851859450e8c3943d0439fc57a3520081eb4.zip
* fhandler.h (fhandler_cygdrive:DRVSZ): New enum.
(pdrive_buf): New place to hold information about cygdrive. * fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Store drive info in pdrive_buf since get_win32_name() could now be too small to hold everything. (fhandler_cygdrive::rewinddir): Reset pdrive to pdrive_buf. (fhandler_cygdrive::closedir): Ditto. * pipe.cc (fhandler_pipe::init): Be more defensive when referencing get_win32_name(). Rework logic which made a copy of the POSIX path and then never used it.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc13
1 files changed, 5 insertions, 8 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 2baabaef3..579c6ef21 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -2123,14 +2123,11 @@ fhandler_cygdrive::close ()
return 0;
}
-#define DRVSZ sizeof ("x:\\")
void
fhandler_cygdrive::set_drives ()
{
- const int len = 2 + 26 * DRVSZ;
- char *p = const_cast<char *> (get_win32_name ());
- pdrive = p;
- ndrives = GetLogicalDriveStrings (len, p) / DRVSZ;
+ pdrive = pdrive_buf;
+ ndrives = GetLogicalDriveStrings (sizeof pdrive_buf, pdrive_buf) / DRVSZ;
}
int
@@ -2146,7 +2143,7 @@ fhandler_cygdrive::fstat (struct __stat64 *buf)
for (const char *p = pdrive; p && *p; p = strchr (p, '\0') + 1)
if (is_floppy ((flptst[0] = *p, flptst))
|| GetFileAttributes (p) == INVALID_FILE_ATTRIBUTES)
- --n;
+ n--;
buf->st_nlink = n + 2;
return 0;
}
@@ -2198,13 +2195,13 @@ fhandler_cygdrive::readdir (DIR *dir, dirent *de)
void
fhandler_cygdrive::rewinddir (DIR *dir)
{
- pdrive = get_win32_name ();
+ pdrive = pdrive_buf;
dir->__d_position = 0;
}
int
fhandler_cygdrive::closedir (DIR *dir)
{
- pdrive = get_win32_name ();
+ pdrive = pdrive_buf;
return 0;
}