зеркало из https://github.com/github/ruby.git
* win32/win32.c (rb_w32_opendir): Corresponds to the unjust path containing ".
(rb_w32_stat) : ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ce296ec7fc
Коммит
94e5dc3416
|
@ -1,3 +1,8 @@
|
||||||
|
Sun Sep 15 21:14:22 2002 KONISHI Hiromasa <konishih@fd6.so-net.ne.jp>
|
||||||
|
|
||||||
|
* win32/win32.c (rb_w32_opendir): Corresponds to the unjust path containing ".
|
||||||
|
(rb_w32_stat) : ditto.
|
||||||
|
|
||||||
Sun Sep 15 19:48:55 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
Sun Sep 15 19:48:55 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in (OUTFLAG, CPPOUTFILE): moved from lib/mkmf.rb.
|
* configure.in (OUTFLAG, CPPOUTFILE): moved from lib/mkmf.rb.
|
||||||
|
|
|
@ -1150,14 +1150,14 @@ NtMakeCmdVector (char *cmdline, char ***vec, int InputCmd)
|
||||||
DIR *
|
DIR *
|
||||||
rb_w32_opendir(const char *filename)
|
rb_w32_opendir(const char *filename)
|
||||||
{
|
{
|
||||||
DIR *p;
|
DIR *p;
|
||||||
long len;
|
long len;
|
||||||
long idx;
|
long idx;
|
||||||
char scannamespc[PATHLEN];
|
char scannamespc[PATHLEN];
|
||||||
char *scanname = scannamespc;
|
char *scanname = scannamespc;
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
WIN32_FIND_DATA FindData;
|
struct _finddata_t fd;
|
||||||
HANDLE fh;
|
long fh;
|
||||||
|
|
||||||
//
|
//
|
||||||
// check to see if we've got a directory
|
// check to see if we've got a directory
|
||||||
|
@ -1165,10 +1165,11 @@ rb_w32_opendir(const char *filename)
|
||||||
|
|
||||||
if ((rb_w32_stat (filename, &sbuf) < 0 ||
|
if ((rb_w32_stat (filename, &sbuf) < 0 ||
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
(unsigned short)(sbuf.st_mode) & _S_IFDIR == 0) &&
|
(unsigned short)(sbuf.st_mode)
|
||||||
#else
|
#else
|
||||||
sbuf.st_mode & _S_IFDIR == 0) &&
|
sbuf.st_mode
|
||||||
#endif
|
#endif
|
||||||
|
& _S_IFDIR == 0) &&
|
||||||
(!ISALPHA(filename[0]) || filename[1] != ':' || filename[2] != '\0' ||
|
(!ISALPHA(filename[0]) || filename[1] != ':' || filename[2] != '\0' ||
|
||||||
((1 << (filename[0] & 0x5f) - 'A') & GetLogicalDrives()) == 0)) {
|
((1 << (filename[0] & 0x5f) - 'A') & GetLogicalDrives()) == 0)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1197,8 +1198,8 @@ rb_w32_opendir(const char *filename)
|
||||||
// do the FindFirstFile call
|
// do the FindFirstFile call
|
||||||
//
|
//
|
||||||
|
|
||||||
fh = FindFirstFile (scanname, &FindData);
|
fh = _findfirst(scanname, &fd);
|
||||||
if (fh == INVALID_HANDLE_VALUE) {
|
if (fh == -1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1207,9 +1208,9 @@ rb_w32_opendir(const char *filename)
|
||||||
// filenames that we find.
|
// filenames that we find.
|
||||||
//
|
//
|
||||||
|
|
||||||
idx = strlen(FindData.cFileName)+1;
|
idx = strlen(fd.name)+1;
|
||||||
p->start = ALLOC_N(char, idx);
|
p->start = ALLOC_N(char, idx);
|
||||||
strcpy (p->start, FindData.cFileName);
|
strcpy(p->start, fd.name);
|
||||||
p->nfiles++;
|
p->nfiles++;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1218,8 +1219,8 @@ rb_w32_opendir(const char *filename)
|
||||||
// the variable idx should point one past the null terminator
|
// the variable idx should point one past the null terminator
|
||||||
// of the previous string found.
|
// of the previous string found.
|
||||||
//
|
//
|
||||||
while (FindNextFile(fh, &FindData)) {
|
while (_findnext(fh, &fd) == 0) {
|
||||||
len = strlen (FindData.cFileName);
|
len = strlen(fd.name);
|
||||||
|
|
||||||
//
|
//
|
||||||
// bump the string table size by enough for the
|
// bump the string table size by enough for the
|
||||||
|
@ -1232,11 +1233,11 @@ rb_w32_opendir(const char *filename)
|
||||||
if (p->start == NULL) {
|
if (p->start == NULL) {
|
||||||
rb_fatal ("opendir: malloc failed!\n");
|
rb_fatal ("opendir: malloc failed!\n");
|
||||||
}
|
}
|
||||||
strcpy(&p->start[idx], FindData.cFileName);
|
strcpy(&p->start[idx], fd.name);
|
||||||
p->nfiles++;
|
p->nfiles++;
|
||||||
idx += len+1;
|
idx += len+1;
|
||||||
}
|
}
|
||||||
FindClose(fh);
|
_findclose(fh);
|
||||||
p->size = idx;
|
p->size = idx;
|
||||||
p->curr = p->start;
|
p->curr = p->start;
|
||||||
return p;
|
return p;
|
||||||
|
@ -2517,6 +2518,12 @@ rb_w32_stat(const char *path, struct stat *st)
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
len = strlen(buf1);
|
len = strlen(buf1);
|
||||||
p = CharPrev(buf1, buf1 + len);
|
p = CharPrev(buf1, buf1 + len);
|
||||||
|
if( '\"' == *(--s) )
|
||||||
|
{
|
||||||
|
errno = EBADF;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (isUNCRoot(buf1)) {
|
if (isUNCRoot(buf1)) {
|
||||||
if (*p != '\\')
|
if (*p != '\\')
|
||||||
strcat(buf1, "\\");
|
strcat(buf1, "\\");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче