comparison src/msdos.c @ 55198:dabd7326e596

(init_environment): If one of the TMP... environment variables is set to a drive letter without a trailing slash, append a slash.
author Eli Zaretskii <eliz@gnu.org>
date Tue, 27 Apr 2004 14:22:05 +0000
parents c33e4ac43939
children d9dc976b92ba 0c11f1f77626
comparison
equal deleted inserted replaced
55197:048eee9ae6ae 55198:dabd7326e596
4406 will break on DOS/Windows. Refuse to work if we cannot find 4406 will break on DOS/Windows. Refuse to work if we cannot find
4407 a directory, not even "c:/", usable for that purpose. */ 4407 a directory, not even "c:/", usable for that purpose. */
4408 for (i = 0; i < imax ; i++) 4408 for (i = 0; i < imax ; i++)
4409 { 4409 {
4410 const char *tmp = tempdirs[i]; 4410 const char *tmp = tempdirs[i];
4411 char buf[FILENAME_MAX];
4411 4412
4412 if (*tmp == '$') 4413 if (*tmp == '$')
4413 tmp = getenv (tmp + 1); 4414 {
4415 int tmp_len;
4416
4417 tmp = getenv (tmp + 1);
4418 if (!tmp)
4419 continue;
4420
4421 /* Some lusers set TMPDIR=e:, probably because some losing
4422 programs cannot handle multiple slashes if they use e:/.
4423 e: fails in `access' below, so we interpret e: as e:/. */
4424 tmp_len = strlen(tmp);
4425 if (tmp[tmp_len - 1] != '/' && tmp[tmp_len - 1] != '\\')
4426 {
4427 strcpy(buf, tmp);
4428 buf[tmp_len++] = '/', buf[tmp_len] = 0;
4429 tmp = buf;
4430 }
4431 }
4432
4414 /* Note that `access' can lie to us if the directory resides on a 4433 /* Note that `access' can lie to us if the directory resides on a
4415 read-only filesystem, like CD-ROM or a write-protected floppy. 4434 read-only filesystem, like CD-ROM or a write-protected floppy.
4416 The only way to be really sure is to actually create a file and 4435 The only way to be really sure is to actually create a file and
4417 see if it succeeds. But I think that's too much to ask. */ 4436 see if it succeeds. But I think that's too much to ask. */
4418 if (tmp && access (tmp, D_OK) == 0) 4437 if (tmp && access (tmp, D_OK) == 0)