Commit 9e041c6b authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

cmd.exe: Add support for FTYPE.

parent 62fff2ea
......@@ -235,4 +235,5 @@ Zadejte HELP <pkaz> pro podrobnj informace o nkterm z ve uvedench pk
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -252,4 +252,5 @@ obigen Befehle erhalten.\n"
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -239,4 +239,5 @@ Enter HELP <command> for further information on any of the above commands\n"
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -247,4 +247,5 @@ Introduzca HELP <comando> para ms informacin sobre cualquiera de los comandos\
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -229,4 +229,5 @@ Entrez HELP <commande> pour plus d'informations sur les commandes ci-dessus\n"
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -233,4 +233,5 @@ EXIT\t\tCMDI\n\n\
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -231,4 +231,5 @@ HELP <명령>을 치면 그 명령의 상세한 정보를 보여줌\n"
WCMD_YES, "예"
WCMD_NO, "아니오"
WCMD_NOASSOC, "이 파일확장자 %s에 연결된 풀그림이 없습니다 \n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -232,4 +232,5 @@ type HELP <opdracht> voor meer informatie over bovengenoemde opdrachten\n"
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -230,4 +230,5 @@ Skriv HELP <kommando> for mer informasjon om kommandoene ovenfor\n"
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -226,4 +226,5 @@ Wpisz HELP <komenda> dla dokadniejszych informacji o komendzie\n"
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -439,4 +439,5 @@ Digite HELP <comando> para mais informaes sobre alguns dos comandos acima\n"
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -245,4 +245,5 @@ EXIT\t\t CMD\n\n\
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -231,4 +231,5 @@ Enter HELP <command> for further information on any of the above commands\n"
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -233,4 +233,5 @@ Yukardaki komutlar hakknda daha fazla bilgi iin HELP <komut> girin\n"
WCMD_YES, "Y"
WCMD_NO, "N"
WCMD_NOASSOC, "File association missing for extension %s\n"
WCMD_NOFTYPE, "No open command associated with file type '%s'\n"
}
......@@ -1615,9 +1615,10 @@ BOOL WCMD_ask_confirm (char *message, BOOL showSureText) {
/*****************************************************************************
* WCMD_assoc
*
* Lists or sets file associations
* Lists or sets file associations (assoc = TRUE)
* Lists or sets file types (assoc = FALSE)
*/
void WCMD_assoc (char *command) {
void WCMD_assoc (char *command, BOOL assoc) {
HKEY key;
DWORD accessOptions = KEY_READ;
......@@ -1657,12 +1658,19 @@ void WCMD_assoc (char *command) {
if (rc == ERROR_SUCCESS) {
/* Only interested in extension ones */
if (keyName[0] == '.') {
/* Only interested in extension ones if assoc, or others
if not assoc */
if ((keyName[0] == '.' && assoc) ||
(!(keyName[0] == '.') && (!assoc)))
{
char subkey[MAXSTRING];
strcpy(subkey, keyName);
if (!assoc) strcat(subkey, "\\Shell\\Open\\Command");
if (RegOpenKeyEx(key, keyName, 0,
if (RegOpenKeyEx(key, subkey, 0,
accessOptions, &readKey) == ERROR_SUCCESS) {
valueLen = sizeof(keyValue);
rc = RegQueryValueEx(readKey, NULL, NULL, NULL,
(LPBYTE)keyValue, &valueLen);
WCMD_output_asis(keyName);
......@@ -1683,13 +1691,18 @@ void WCMD_assoc (char *command) {
/* Parameter supplied - if no '=' on command line, its a query */
if (newValue == NULL) {
char *space;
char subkey[MAXSTRING];
/* Query terminates the parameter at the first space */
strcpy(keyValue, command);
space = strchr(keyValue, ' ');
if (space) *space=0x00;
if (RegOpenKeyEx(key, keyValue, 0,
/* Set up key name */
strcpy(subkey, keyValue);
if (!assoc) strcat(subkey, "\\Shell\\Open\\Command");
if (RegOpenKeyEx(key, subkey, 0,
accessOptions, &readKey) == ERROR_SUCCESS) {
rc = RegQueryValueEx(readKey, NULL, NULL, NULL,
......@@ -1706,7 +1719,11 @@ void WCMD_assoc (char *command) {
char outbuffer[MAXSTRING];
/* Load the translated 'File association not found' */
LoadString (hinst, WCMD_NOASSOC, msgbuffer, sizeof(msgbuffer));
if (assoc) {
LoadString (hinst, WCMD_NOASSOC, msgbuffer, sizeof(msgbuffer));
} else {
LoadString (hinst, WCMD_NOFTYPE, msgbuffer, sizeof(msgbuffer));
}
sprintf(outbuffer, msgbuffer, keyValue);
WCMD_output_asis(outbuffer);
errorlevel = 2;
......@@ -1715,18 +1732,24 @@ void WCMD_assoc (char *command) {
/* Not a query - its a set or clear of a value */
} else {
char subkey[MAXSTRING];
/* Get pointer to new value */
*newValue = 0x00;
newValue++;
/* If nothing after '=' then clear value */
/* Set up key name */
strcpy(subkey, command);
if (!assoc) strcat(subkey, "\\Shell\\Open\\Command");
/* If nothing after '=' then clear value - only valid for ASSOC */
if (*newValue == 0x00) {
rc = RegDeleteKey(key, command);
if (rc == ERROR_SUCCESS) {
if (assoc) rc = RegDeleteKey(key, command);
if (assoc && rc == ERROR_SUCCESS) {
WINE_TRACE("HKCR Key '%s' deleted\n", command);
} else if (rc != ERROR_FILE_NOT_FOUND) {
} else if (assoc && rc != ERROR_FILE_NOT_FOUND) {
WCMD_print_error();
errorlevel = 2;
......@@ -1735,7 +1758,11 @@ void WCMD_assoc (char *command) {
char outbuffer[MAXSTRING];
/* Load the translated 'File association not found' */
LoadString (hinst, WCMD_NOASSOC, msgbuffer, sizeof(msgbuffer));
if (assoc) {
LoadString (hinst, WCMD_NOASSOC, msgbuffer, sizeof(msgbuffer));
} else {
LoadString (hinst, WCMD_NOFTYPE, msgbuffer, sizeof(msgbuffer));
}
sprintf(outbuffer, msgbuffer, keyValue);
WCMD_output_asis(outbuffer);
errorlevel = 2;
......@@ -1743,7 +1770,7 @@ void WCMD_assoc (char *command) {
/* It really is a set value = contents */
} else {
rc = RegCreateKeyEx(key, command, 0, NULL, REG_OPTION_NON_VOLATILE,
rc = RegCreateKeyEx(key, subkey, 0, NULL, REG_OPTION_NON_VOLATILE,
accessOptions, NULL, &readKey, NULL);
if (rc == ERROR_SUCCESS) {
rc = RegSetValueEx(readKey, NULL, 0, REG_SZ,
......
......@@ -27,7 +27,7 @@
#include <stdio.h>
#include <ctype.h>
void WCMD_assoc (char *);
void WCMD_assoc (char *, BOOL);
void WCMD_batch (char *, char *, int, char *, HANDLE);
void WCMD_call (char *command);
void WCMD_change_tty (void);
......@@ -162,9 +162,10 @@ struct env_stack
#define WCMD_POPD 39
#define WCMD_ASSOC 40
#define WCMD_COLOR 41
#define WCMD_FTYPE 42
/* Must be last in list */
#define WCMD_EXIT 42
#define WCMD_EXIT 43
/* Some standard messages */
extern const char nyi[];
......@@ -177,6 +178,7 @@ extern const char anykey[];
#define WCMD_YES 1002
#define WCMD_NO 1003
#define WCMD_NOASSOC 1004
#define WCMD_NOFTYPE 1005
/* msdn specified max for Win XP */
#define MAXSTRING 8192
......@@ -35,7 +35,8 @@ const char * const inbuilt[] = {"ATTRIB", "CALL", "CD", "CHDIR", "CLS", "COPY",
"HELP", "IF", "LABEL", "MD", "MKDIR", "MOVE", "PATH", "PAUSE",
"PROMPT", "REM", "REN", "RENAME", "RD", "RMDIR", "SET", "SHIFT",
"TIME", "TITLE", "TYPE", "VERIFY", "VER", "VOL",
"ENDLOCAL", "SETLOCAL", "PUSHD", "POPD", "ASSOC", "COLOR", "EXIT" };
"ENDLOCAL", "SETLOCAL", "PUSHD", "POPD", "ASSOC", "COLOR", "FTYPE",
"EXIT" };
HINSTANCE hinst;
DWORD errorlevel;
......@@ -657,11 +658,14 @@ void WCMD_process_command (char *command)
WCMD_popd();
break;
case WCMD_ASSOC:
WCMD_assoc(p);
WCMD_assoc(p, TRUE);
break;
case WCMD_COLOR:
WCMD_color();
break;
case WCMD_FTYPE:
WCMD_assoc(p, FALSE);
break;
case WCMD_EXIT:
WCMD_exit ();
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment