下载notepad++的代码,用Visual Studio 2005打开notepadplus.sln.
修改notepad_plus.cpp中的fileSave()方法,并重新编译。
修改后的代码如下,很初级的修改,还只适合自己使用。
bool Notepad_plus::fileSave()
{
if (_pEditView->isCurrentDocDirty())
{
const char *fn = _pEditView->getCurrentTitle();
if (Buffer::isUntitled(fn))
{
//return fileSaveAs();
string fn_quickfile = "E://LouGnib4Office//PortableWork//20070705-myFiles//QuickSave//";
const int temBufLen = 32;
char tmpbuf[temBufLen];
time_t ltime = time(0);
struct tm *today;
today = localtime(<ime);
strftime(tmpbuf, temBufLen, "%Y%m%d%H%M%S", today);
fn_quickfile += tmpbuf;
fn_quickfile += ".txt";
const char *pfn = fn_quickfile.c_str();
doSave(pfn, _pEditView->getCurrentBuffer().getUnicodeMode());
_pEditView->setCurrentTitle(pfn);
_pEditView->setCurrentDocReadOnly(false);
_pDocTab->updateCurrentTabItem(PathFindFileName(pfn));
setTitleWith(pfn);
setLangStatus(_pEditView->getCurrentDocType());
checkLangsMenu(-1);
return true;
}
else
{
const NppGUI & nppgui = (NppParameters::getInstance())->getNppGUI();
BackupFeature backup = nppgui._backup;
if (backup == bak_simple)
{
//copy fn to fn.backup
string fn_bak(fn);
if ((nppgui._useDir) && (nppgui._backupDir[0] != '/0'))
{
char path[MAX_PATH];
char *name;
strcpy(path, fn);
name = ::PathFindFileName(path);
fn_bak = nppgui._backupDir;
fn_bak += "//";
fn_bak += name;
}
else
{
fn_bak = fn;
}
fn_bak += ".bak";
::CopyFile(fn, fn_bak.c_str(), FALSE);
}
else if (backup == bak_verbose)
{
char path[MAX_PATH];
char *name;
string fn_dateTime_bak;
strcpy(path, fn);
name = ::PathFindFileName(path);
::PathRemoveFileSpec(path);
if ((nppgui._useDir) && (nppgui._backupDir[0] != '/0'))
{//printStr(nppgui._backupDir);
fn_dateTime_bak = nppgui._backupDir;
fn_dateTime_bak += "//";
}
else
{
const char *bakDir = "nppBackup";
fn_dateTime_bak = path;
fn_dateTime_bak += "//";
fn_dateTime_bak += bakDir;
fn_dateTime_bak += "//";
if (!::PathFileExists(fn_dateTime_bak.c_str()))
{
::CreateDirectory(bakDir, NULL);
}
}
fn_dateTime_bak += name;
const int temBufLen = 32;
char tmpbuf[temBufLen];
time_t ltime = time(0);
struct tm *today;
today = localtime(<ime);
strftime(tmpbuf, temBufLen, "%Y-%m-%d_%H%M%S", today);
fn_dateTime_bak += ".";
fn_dateTime_bak += tmpbuf;
fn_dateTime_bak += ".bak";
::CopyFile(fn, fn_dateTime_bak.c_str(), FALSE);
}
return doSave(fn, _pEditView->getCurrentBuffer().getUnicodeMode());
}
}
return false;
}