From 1697b664b194bc12dd8e9870cb3ac10524fa79b5 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 1 May 2012 12:20:18 +0000 Subject: [PATCH] [BUG_FIXED] Fix a bug while command argument is empty (""). [NEW_FEATURE] Warn user while the amount of file to open is larger than 200. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@904 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/NppIO.cpp | 20 ++++++++++++++++++-- PowerEditor/src/winmain.cpp | 25 ++++++++++++++----------- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 9d1dc995..9bf664ae 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -190,9 +190,25 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encodi fileNameStr += TEXT("\\"); getMatchedFileNames(fileNameStr.c_str(), patterns, fileNames, true, false); - for (size_t i = 0 ; i < fileNames.size() ; i++) + size_t nbFiles2Open = fileNames.size(); + + bool ok2Open = true; + if (nbFiles2Open > 200) { - doOpen(fileNames[i].c_str()); + int answer = _nativeLangSpeaker.messageBox("NbFileToOpenImportantWaring", + _pPublicInterface->getHSelf(), + TEXT("Number of files to open are too important.\rAre you sure to open them?"), + TEXT("Number of files to open is too large"), + MB_YESNO|MB_APPLMODAL); + ok2Open = answer != IDYES; + } + + if (ok2Open) + { + for (size_t i = 0 ; i < nbFiles2Open ; i++) + { + doOpen(fileNames[i].c_str()); + } } } else diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index 98e1d321..3bea3607 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -244,19 +244,22 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) for(size_t i = 0; i < nrFilesToOpen; i++) { currentFile = params.at(i); - //check if relative or full path. Relative paths dont have a colon for driveletter - BOOL isRelative = ::PathIsRelative(currentFile); - quotFileName += TEXT("\""); - if (isRelative) + if (currentFile[0]) { - ::GetFullPathName(currentFile, MAX_PATH, fullFileName, NULL); - quotFileName += fullFileName; + //check if relative or full path. Relative paths dont have a colon for driveletter + BOOL isRelative = ::PathIsRelative(currentFile); + quotFileName += TEXT("\""); + if (isRelative) + { + ::GetFullPathName(currentFile, MAX_PATH, fullFileName, NULL); + quotFileName += fullFileName; + } + else + { + quotFileName += currentFile; + } + quotFileName += TEXT("\" "); } - else - { - quotFileName += currentFile; - } - quotFileName += TEXT("\" "); } //Only after loading all the file paths set the working directory