mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-29 16:54:43 +02:00
[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
This commit is contained in:
parent
7e195e3058
commit
f5b8eace0a
@ -220,11 +220,16 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const char *cmdLine, CmdLi
|
|||||||
|
|
||||||
if (cmdLine)
|
if (cmdLine)
|
||||||
{
|
{
|
||||||
|
char currPath[MAX_PATH];
|
||||||
|
::GetCurrentDirectory(sizeof currPath, currPath);
|
||||||
|
::SetCurrentDirectory(currPath);
|
||||||
|
|
||||||
LangType lt = cmdLineParams->_langType;
|
LangType lt = cmdLineParams->_langType;
|
||||||
int ln = cmdLineParams->_line2go;
|
int ln = cmdLineParams->_line2go;
|
||||||
|
|
||||||
if (PathFileExists(cmdLine))
|
if (PathFileExists(cmdLine))
|
||||||
{
|
{
|
||||||
|
|
||||||
doOpen(cmdLine, cmdLineParams->_isReadOnly);
|
doOpen(cmdLine, cmdLineParams->_isReadOnly);
|
||||||
|
|
||||||
if (lt != L_TXT)
|
if (lt != L_TXT)
|
||||||
@ -417,13 +422,26 @@ bool Notepad_plus::doOpen(const char *fileName, bool isReadOnly)
|
|||||||
|
|
||||||
if (!PathFileExists(longFileName))
|
if (!PathFileExists(longFileName))
|
||||||
{
|
{
|
||||||
char str2display[128];
|
char str2display[MAX_PATH*2];
|
||||||
sprintf(str2display, "%s doesn't exist. Create it?", longFileName);
|
char longFileDir[MAX_PATH];
|
||||||
|
|
||||||
if (::MessageBox(_hSelf, str2display, "Create new file", MB_YESNO) == IDYES)
|
strcpy(longFileDir, longFileName);
|
||||||
|
PathRemoveFileSpec(longFileDir);
|
||||||
|
|
||||||
|
if (PathFileExists(longFileDir))
|
||||||
{
|
{
|
||||||
FILE *f = fopen(longFileName, "w");
|
sprintf(str2display, "%s doesn't exist. Create it?", longFileName);
|
||||||
fclose(f);
|
|
||||||
|
if (::MessageBox(_hSelf, str2display, "Create new file", MB_YESNO) == IDYES)
|
||||||
|
{
|
||||||
|
FILE *f = fopen(longFileName, "w");
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_lastRecentFileList.remove(longFileName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -641,7 +641,7 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM
|
|||||||
for (int i = L_TXT ; i < L_END ; i++)
|
for (int i = L_TXT ; i < L_END ; i++)
|
||||||
{
|
{
|
||||||
string str;
|
string str;
|
||||||
//if ((LangType)i != L_END)
|
if ((LangType)i != L_USER)
|
||||||
{
|
{
|
||||||
int cmdID = pNppParam->langTypeToCommandID((LangType)i);
|
int cmdID = pNppParam->langTypeToCommandID((LangType)i);
|
||||||
if ((cmdID != -1) && (getNameStrFromCmd(cmdID, str) == TYPE_CMD))
|
if ((cmdID != -1) && (getNameStrFromCmd(cmdID, str) == TYPE_CMD))
|
||||||
|
@ -200,7 +200,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, int nCmdSh
|
|||||||
cmdLineParams._isNoPlugin = isInList(FLAG_NO_PLUGIN, lpszCmdLine);
|
cmdLineParams._isNoPlugin = isInList(FLAG_NO_PLUGIN, lpszCmdLine);
|
||||||
cmdLineParams._isReadOnly = isInList(FLAG_READONLY, lpszCmdLine);
|
cmdLineParams._isReadOnly = isInList(FLAG_READONLY, lpszCmdLine);
|
||||||
cmdLineParams._isNoSession = isInList(FLAG_NOSESSION, lpszCmdLine);
|
cmdLineParams._isNoSession = isInList(FLAG_NOSESSION, lpszCmdLine);
|
||||||
//printStr(cmdLineParams._isReadOnly?"RO":"RW");
|
|
||||||
cmdLineParams._langType = getLangTypeFromParam(lpszCmdLine);
|
cmdLineParams._langType = getLangTypeFromParam(lpszCmdLine);
|
||||||
cmdLineParams._line2go = getLn2GoFromParam(lpszCmdLine);
|
cmdLineParams._line2go = getLn2GoFromParam(lpszCmdLine);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user