diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 350a6a5be..95f898a06 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -159,22 +159,25 @@ BufferID Notepad_plus::doOpen(const generic_string& fileName, bool isRecursive, //If the lpBuffer buffer is too small to contain the path, the return value [of GetFullPathName] is the size, in TCHARs, of the buffer that is required to hold the path and the terminating null character. //If [GetFullPathName] fails for any other reason, the return value is zero. - NppParameters *pNppParam = NppParameters::getInstance(); - TCHAR longFileName[longFileNameBufferSize]; + NppParameters *pNppParam = NppParameters::getInstance(); + TCHAR longFileName[longFileNameBufferSize]; - const DWORD getFullPathNameResult = ::GetFullPathName(fileName.c_str(), longFileNameBufferSize, longFileName, NULL); - if ( getFullPathNameResult == 0 ) + const DWORD getFullPathNameResult = ::GetFullPathName(fileName.c_str(), longFileNameBufferSize, longFileName, NULL); + if (getFullPathNameResult == 0) { return BUFFER_INVALID; } - if ( getFullPathNameResult > longFileNameBufferSize ) + if (getFullPathNameResult > longFileNameBufferSize) { return BUFFER_INVALID; } - assert( _tcslen( longFileName ) == getFullPathNameResult ); + assert(_tcslen(longFileName) == getFullPathNameResult); - // ignore the returned value of function due to win64 redirection system - ::GetLongPathName(longFileName, longFileName, longFileNameBufferSize); + if (_tcschr(longFileName, '~')) + { + // ignore the returned value of function due to win64 redirection system + ::GetLongPathName(longFileName, longFileName, longFileNameBufferSize); + } bool isSnapshotMode = backupFileName != NULL && PathFileExists(backupFileName); if (isSnapshotMode && !PathFileExists(longFileName)) // UNTITLED diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 0f3a8758b..b7827f5f8 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -581,7 +581,10 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin TCHAR fullpath[MAX_PATH]; ::GetFullPathName(filename, MAX_PATH, fullpath, NULL); - ::GetLongPathName(fullpath, fullpath, MAX_PATH); + if (_tcschr(fullpath, '~')) + { + ::GetLongPathName(fullpath, fullpath, MAX_PATH); + } bool isSnapshotMode = backupFileName != NULL && PathFileExists(backupFileName); if (isSnapshotMode && !PathFileExists(fullpath)) // if backup mode and fullpath doesn't exist, we guess is UNTITLED @@ -850,7 +853,10 @@ bool FileManager::backupCurrentBuffer() TCHAR fullpath[MAX_PATH]; ::GetFullPathName(backupFilePath.c_str(), MAX_PATH, fullpath, NULL); - ::GetLongPathName(fullpath, fullpath, MAX_PATH); + if (_tcschr(fullpath, '~')) + { + ::GetLongPathName(fullpath, fullpath, MAX_PATH); + } // Make sure the backup file is not read only DWORD dwFileAttribs = ::GetFileAttributes(fullpath); @@ -1024,7 +1030,11 @@ bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy, g TCHAR fullpath[MAX_PATH]; ::GetFullPathName(filename, MAX_PATH, fullpath, NULL); - ::GetLongPathName(fullpath, fullpath, MAX_PATH); + if (_tcschr(fullpath, '~')) + { + ::GetLongPathName(fullpath, fullpath, MAX_PATH); + } + if (PathFileExists(fullpath)) { attrib = ::GetFileAttributes(fullpath); @@ -1501,7 +1511,10 @@ BufferID FileManager::getBufferFromName(const TCHAR* name) { TCHAR fullpath[MAX_PATH]; ::GetFullPathName(name, MAX_PATH, fullpath, NULL); - ::GetLongPathName(fullpath, fullpath, MAX_PATH); + if (_tcschr(fullpath, '~')) + { + ::GetLongPathName(fullpath, fullpath, MAX_PATH); + } for(size_t i = 0; i < _buffers.size(); i++) {