Notepad will no longer add .txt if you invoke it specifying a file that does not exist, but has a file extension Modified: trunk/reactos/subsys/system/notepad/dialog.c Modified: trunk/reactos/subsys/system/notepad/dialog.h Modified: trunk/reactos/subsys/system/notepad/main.c _____
Modified: trunk/reactos/subsys/system/notepad/dialog.c --- trunk/reactos/subsys/system/notepad/dialog.c 2005-10-24 22:02:39 UTC (rev 18764) +++ trunk/reactos/subsys/system/notepad/dialog.c 2005-10-24 23:44:07 UTC (rev 18765) @@ -139,6 +139,17 @@
}
+BOOL HasFileExtension(LPCWSTR szFilename) +{ + LPCWSTR s; + + s = wcsrchr(szFilename, '\'); + if (s) + szFilename = s; + return wcsrchr(szFilename, '.') != NULL; +} + + static VOID DoSaveFile(VOID) { HANDLE hFile; _____
Modified: trunk/reactos/subsys/system/notepad/dialog.h --- trunk/reactos/subsys/system/notepad/dialog.h 2005-10-24 22:02:39 UTC (rev 18764) +++ trunk/reactos/subsys/system/notepad/dialog.h 2005-10-24 23:44:07 UTC (rev 18765) @@ -55,5 +55,6 @@
/* utility functions */ VOID ShowLastError(void); BOOL FileExists(LPCWSTR szFilename); +BOOL HasFileExtension(LPCWSTR szFilename); BOOL DoCloseFile(void); void DoOpenFile(LPCWSTR szFileName); _____
Modified: trunk/reactos/subsys/system/notepad/main.c --- trunk/reactos/subsys/system/notepad/main.c 2005-10-24 22:02:39 UTC (rev 18764) +++ trunk/reactos/subsys/system/notepad/main.c 2005-10-24 23:44:07 UTC (rev 18765) @@ -440,8 +440,8 @@
if (*cmdline) { /* file name is passed in the command line */ - LPCWSTR file_name; - BOOL file_exists; + LPCWSTR file_name = NULL; + BOOL file_exists = FALSE; WCHAR buf[MAX_PATH];
if (cmdline[0] == '"') @@ -455,7 +455,7 @@ file_exists = TRUE; file_name = cmdline; } - else + else if (!HasFileExtension(cmdline)) { static const WCHAR txtW[] = { '.','t','x','t',0 };
@@ -463,7 +463,6 @@ if (!lstrcmp(txtW, cmdline + lstrlen(cmdline) - lstrlen(txtW))) { file_exists = FALSE; - file_name = cmdline; } else { @@ -476,6 +475,7 @@
if (file_exists) { + file_name = cmdline; DoOpenFile(file_name); InvalidateRect(Globals.hMainWnd, NULL, FALSE); if (opt_print)