Browse Source

[BUG_FIXED_AND_NEW_FEATURE] Add open relative file path from command line feature.

Fix the crash issue when open a file which does not exist anymore from RFL (if its path exceed certain length).
 

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@65 f5eea248-9336-0410-98b8-ebc06183d4e3
pull/343/head^2
donho 17 years ago
parent
commit
f5b8eace0a
  1. 28
      PowerEditor/src/Notepad_plus.cpp
  2. 2
      PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
  3. 1
      PowerEditor/src/winmain.cpp

28
PowerEditor/src/Notepad_plus.cpp

@ -220,11 +220,16 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLi
if (cmdLine)
{
char currPath[MAX_PATH];
::GetCurrentDirectory(sizeof currPath, currPath);
::SetCurrentDirectory(currPath);
LangType lt = cmdLineParams->_langType;
int ln = cmdLineParams->_line2go;
if (PathFileExists(cmdLine))
{
doOpen(cmdLine, cmdLineParams->_isReadOnly);
if (lt != L_TXT)
@ -417,13 +422,26 @@ bool Notepad_plus::doOpen(const char *fileName, bool isReadOnly)
if (!PathFileExists(longFileName))
{
char str2display[128];
sprintf(str2display, "%s doesn't exist. Create it?", longFileName);
char str2display[MAX_PATH*2];
char longFileDir[MAX_PATH];
strcpy(longFileDir, longFileName);
PathRemoveFileSpec(longFileDir);
if (::MessageBox(_hSelf, str2display, "Create new file", MB_YESNO) == IDYES)
if (PathFileExists(longFileDir))
{
FILE *f = fopen(longFileName, "w");
fclose(f);
sprintf(str2display, "%s doesn't exist. Create it?", longFileName);
if (::MessageBox(_hSelf, str2display, "Create new file", MB_YESNO) == IDYES)
{
FILE *f = fopen(longFileName, "w");
fclose(f);
}
else
{
_lastRecentFileList.remove(longFileName);
return false;
}
}
else
{

2
PowerEditor/src/WinControls/Preference/preferenceDlg.cpp

@ -641,7 +641,7 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
for (int i = L_TXT ; i < L_END ; i++)
{
string str;
//if ((LangType)i != L_END)
if ((LangType)i != L_USER)
{
int cmdID = pNppParam->langTypeToCommandID((LangType)i);
if ((cmdID != -1) && (getNameStrFromCmd(cmdID, str) == TYPE_CMD))

1
PowerEditor/src/winmain.cpp

@ -200,7 +200,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh
cmdLineParams._isNoPlugin = isInList(FLAG_NO_PLUGIN, lpszCmdLine);
cmdLineParams._isReadOnly = isInList(FLAG_READONLY, lpszCmdLine);
cmdLineParams._isNoSession = isInList(FLAG_NOSESSION, lpszCmdLine);
//printStr(cmdLineParams._isReadOnly?"RO":"RW");
cmdLineParams._langType = getLangTypeFromParam(lpszCmdLine);
cmdLineParams._line2go = getLn2GoFromParam(lpszCmdLine);

Loading…
Cancel
Save