[NEW] Add new command line argument "-r" for opening files recursively (with wildcard characters).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1194 f5eea248-9336-0410-98b8-ebc06183d4e3
remotes/trunk
Don Ho 2014-03-05 21:18:05 +00:00
parent 98cf4f3abd
commit 282d0ea9a9
5 changed files with 14 additions and 10 deletions

View File

@ -4677,14 +4677,14 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam
LangType lt = pCmdParams->_langType;
int ln = pCmdParams->_line2go;
int cn = pCmdParams->_column2go;
bool recursive = pCmdParams->_isRecursive;
bool readOnly = pCmdParams->_isReadOnly;
BufferID lastOpened = BUFFER_INVALID;
for (int i = 0, len = fnss.size(); i < len ; ++i)
{
pFn = fnss.getFileName(i);
BufferID bufID = doOpen(pFn, readOnly);
BufferID bufID = doOpen(pFn, recursive, readOnly);
if (bufID == BUFFER_INVALID) //cannot open file
continue;

View File

@ -220,7 +220,7 @@ public:
// fileOperations
//The doXXX functions apply to a single buffer and dont need to worry about views, with the excpetion of doClose, since closing one view doesnt have to mean the document is gone
BufferID doOpen(const TCHAR *fileName, bool isReadOnly = false, int encoding = -1);
BufferID doOpen(const TCHAR *fileName, bool isRecursive = false, bool isReadOnly = false, int encoding = -1);
bool doReload(BufferID id, bool alert = true);
bool doSave(BufferID, const TCHAR * filename, bool isSaveCopy = false);
void doClose(BufferID, int whichOne);

View File

@ -35,7 +35,7 @@
#include <TCHAR.h>
BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encoding)
BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isRecursive, bool isReadOnly, int encoding)
{
NppParameters *pNppParam = NppParameters::getInstance();
TCHAR longFileName[MAX_PATH];
@ -191,7 +191,7 @@ BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly, int encodi
patterns.push_back(substring + 1);
generic_string dir(fileName, pos + 1);
getMatchedFileNames(dir.c_str(), patterns, fileNames, true, false);
getMatchedFileNames(dir.c_str(), patterns, fileNames, isRecursive, false);
}
else
{
@ -1111,7 +1111,7 @@ bool Notepad_plus::loadSession(Session & session)
}
if (PathFileExists(pFn))
{
lastOpened = doOpen(pFn, false, session._mainViewFiles[i]._encoding);
lastOpened = doOpen(pFn, false, false, session._mainViewFiles[i]._encoding);
}
else
{
@ -1194,7 +1194,7 @@ bool Notepad_plus::loadSession(Session & session)
}
if (PathFileExists(pFn))
{
lastOpened = doOpen(pFn, false, session._subViewFiles[k]._encoding);
lastOpened = doOpen(pFn, false, false, session._subViewFiles[k]._encoding);
//check if already open in main. If so, clone
if (_mainDocTab.getIndexByBuffer(lastOpened) != -1) {

View File

@ -177,7 +177,6 @@ struct CmdLineParams {
bool _isPreLaunch;
bool _showLoadingTime;
bool _alwaysOnTop;
int _line2go;
int _column2go;
@ -188,6 +187,7 @@ struct CmdLineParams {
return _isPointXValid && _isPointYValid;
};
bool _isSessionFile;
bool _isRecursive;
LangType _langType;
generic_string _localizationPath;

View File

@ -188,10 +188,11 @@ const TCHAR FLAG_LOADINGTIME[] = TEXT("-loadingTime");
const TCHAR FLAG_HELP[] = TEXT("--help");
const TCHAR FLAG_ALWAYS_ON_TOP[] = TEXT("-alwaysOnTop");
const TCHAR FLAG_OPENSESSIONFILE[] = TEXT("-openSession");
const TCHAR FLAG_RECURSIVE[] = TEXT("-r");
const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\
\r\
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-xPos] [-yPos] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [fullFilePathName]\r\
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-xPos] [-yPos] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [-alwaysOnTop] [-openSession] [-r] [fullFilePathName]\r\
\r\
--help : This help message\r\
-multiInst : Launch another Notepad++ instance\r\
@ -211,7 +212,9 @@ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNum
-loadingTime : Display Notepad++ loading time\r\
-alwaysOnTop : Make Notepad++ always on top\r\
-openSession : Open a specific session. fullFilePathName must be a session file\r\
fullFilePathName : file name to open (absolute or relative path name)\r\
-r : Open files recursively. This argument will be ignored\r\
if fullFilePathName contain no wildcard character\r\
fullFilePathName : file or folder name to open (absolute or relative path name)\r\
");
void doException(Notepad_plus_Window & notepad_plus_plus);
@ -243,6 +246,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
cmdLineParams._alwaysOnTop = isInList(FLAG_ALWAYS_ON_TOP, params);
cmdLineParams._showLoadingTime = isInList(FLAG_LOADINGTIME, params);
cmdLineParams._isSessionFile = isInList(FLAG_OPENSESSIONFILE, params);
cmdLineParams._isRecursive = isInList(FLAG_RECURSIVE, params);
cmdLineParams._langType = getLangTypeFromParam(params);
cmdLineParams._localizationPath = getLocalizationPathFromParam(params);
cmdLineParams._line2go = getNumberFromParam('n', params, isParamePresent);