Use proper file sharing parameters when opening files.

Fixed handling of 'if a == b' syntax in batch files.
This commit is contained in:
Alexandre Julliard 2003-01-15 03:35:32 +00:00
parent 8be60f8212
commit 36bf792fd7
3 changed files with 12 additions and 7 deletions

View File

@ -54,7 +54,8 @@ BATCH_CONTEXT *prev_context;
strcpy (string, file);
CharLower (string);
if (strstr (string, ".bat") == NULL) strcat (string, ".bat");
h = CreateFile (string, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) {
SetLastError (ERROR_FILE_NOT_FOUND);
WCMD_print_error ();

View File

@ -389,25 +389,28 @@ char condition[MAX_PATH], *command, *s;
if (!lstrcmpi (condition, "errorlevel")) {
if (errorlevel >= atoi(WCMD_parameter (p, 1+negate, NULL))) test = 1;
return;
WCMD_parameter (p, 2+negate, &command);
}
else if (!lstrcmpi (condition, "exist")) {
if ((h = CreateFile (WCMD_parameter (p, 1+negate, NULL), GENERIC_READ, 0, NULL,
if ((h = CreateFile (WCMD_parameter (p, 1+negate, NULL), GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) {
CloseHandle (h);
test = 1;
}
WCMD_parameter (p, 2+negate, &command);
}
else if ((s = strstr (p, "=="))) {
s += 2;
if (!lstrcmpi (condition, WCMD_parameter (s, 0, NULL))) test = 1;
WCMD_parameter (s, 1, &command);
}
else {
WCMD_output ("Syntax error\n");
return;
}
if (test != negate) {
WCMD_parameter (p, 2+negate, &s);
command = strdup (s);
command = strdup (command);
WCMD_process_command (command);
free (command);
}

View File

@ -106,7 +106,7 @@ HANDLE h;
*/
GetFullPathName ("\\autoexec.bat", sizeof(string), string, NULL);
h = CreateFile (string, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h != INVALID_HANDLE_VALUE) {
CloseHandle (h);
#if 0
@ -181,7 +181,7 @@ char *whichcmd;
*/
if ((p = strchr(cmd,'<')) != NULL) {
h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_READ, 0, NULL, OPEN_EXISTING,
h = CreateFile (WCMD_parameter (++p, 0, NULL), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) {
WCMD_print_error ();
@ -383,7 +383,8 @@ char filetorun[MAX_PATH];
if (strchr (param1, '.') == NULL) {
strcpy (filetorun, param1);
strcat (filetorun, ".bat");
h = CreateFile (filetorun, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
h = CreateFile (filetorun, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h != INVALID_HANDLE_VALUE) {
CloseHandle (h);
WCMD_batch (param1, command, 0);