See next post.
Code: Select all
function Rename()
{
var nPan2 = Number(! nCurPan);
var sOldName;
var sNewName;
var sCaption;
if (! RenameAvailable())
return;
GetCurFile(nPan2);
if (aCurWnd[nCurPan] == 0)
{
sOldName = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
if (CurFileIsDir(nCurPan))
sCaption = sTxtRenDir;
else
sCaption = sTxtRenFile;
}
else
{
sOldName = aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
sCaption = sTxtRenStr;
}
sNewName = GetFileName(sCaption, sOldName + "\n\n" + sTxtNewName, sOldName);
if ((sNewName) && (sNewName != sOldName))
{
if (! IsDriveExists(aCurDrive[nCurPan]))
{
MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
return;
}
if (! GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
{
MessageNoFile(nCurPan, CurFileIsDir(nCurPan));
return;
}
//Rename file or directory
if (aCurWnd[nCurPan] == 0)
{
//File or directory already exists
if (GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sNewName))
{
if (IsDirExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sNewName))
WarningBox(hWndDlg, sNewName + "\n\n" + sTxtDirExists, sCaption);
else
WarningBox(hWndDlg, sNewName + "\n\n" + sTxtFileExists, sCaption);
FillFileList(nCurPan, sNewName, 0, 1);
}
else
{
if (RenameFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sOldName, 0, sNewName))
{
FillFileList(nCurPan, sNewName, 0, 1);
if (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path)
RefreshPanel(nPan2);
}
else
WarningBox(hWndDlg, sTxtRenFail, sCaption);
}
}
//Rename stream
else
{
if (IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sOldName))
{
ShowWaitWindow(1);
if (RenameFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sOldName, sNewName))
{
ShowWaitWindow(0);
FillStreamList(nCurPan, sNewName);
if ((aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nPan2][aCurDrive[nPan2]].File))
RefreshStreamList(nPan2);
}
else
{
ShowWaitWindow(0);
WarningBox(hWndDlg, sTxtRenFail, sCaption);
}
}
else
MessageNoStream(sOldName);
}
}
}
function RenameAvailable()
{
GetCurFile(nCurPan);
return aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
(((aCurWnd[nCurPan] == 0) && (aCurDir[nCurPan][aCurDrive[nCurPan]].File != "..")) ||
((aCurWnd[nCurPan] == 1) && aCurDir[nCurPan][aCurDrive[nCurPan]].Stream));
}
function OpenIn(nAppType, nAppIndex)
{
var sAppName;
var sAppPar;
if (! OpenInAvailable(nAppType))
return;
if (nAppType == 0)
sAppName = (nAppIndex == 1) ? sViewer : sViewer2;
else if (nAppType == 1)
sAppName = (nAppIndex == 1) ? sEditor : sEditor2;
else if (nAppType == 3)
sAppName = aFavorite[nAppIndex][1];
else
{
nAppIndex = GetInternalAssocIndex();
if (nAppIndex < 0)
return;
sAppName = aIntAssoc[nAppIndex][1];
}
sAppName = ExpandFileName(sAppName);
if (! IsFileExists(sAppName))
{
if (nAppType == 4)
{
if (SetInternalAssoc(nAppIndex, 1))
{
nAppIndex = GetInternalAssocIndex();
if (nAppIndex < 0)
return;
sAppName = aIntAssoc[nAppIndex][1];
}
else
return;
}
else
{
if (SetExternalApp(nAppType, nAppIndex, 1))
{
if (nAppType == 0)
sAppName = (nAppIndex == 1) ? sViewer : sViewer2;
else if (nAppType == 1)
sAppName = (nAppIndex == 1) ? sEditor : sEditor2;
else
sAppName = aFavorite[nAppIndex][1];
}
else
return;
}
sAppName = ExpandFileName(sAppName);
}
if (! IsDriveExists(aCurDrive[nCurPan]))
{
MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
return;
}
if (! GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
{
MessageNoFile(nCurPan, CurFileIsDir(nCurPan));
return;
}
if (nAppType == 0)
sAppPar = (nAppIndex == 1) ? sViewerPar : sViewerPar2;
else if (nAppType == 1)
sAppPar = (nAppIndex == 1) ? sEditorPar : sEditorPar2;
else if (nAppType == 3)
sAppPar = aFavorite[nAppIndex][2];
else
sAppPar = aIntAssoc[nAppIndex][2];
if ((aCurWnd[nCurPan] == 0) || (! aCurDir[nCurPan][aCurDrive[nCurPan]].Stream))
AkelPad.Exec(sAppName + ' ' + sAppPar + ' "' + aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File + '"');
else
{
if (IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, aCurDir[nCurPan][aCurDrive[nCurPan]].Stream))
AkelPad.Exec(sAppName + ' ' + sAppPar + ' "' + aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File + ':' + aCurDir[nCurPan][aCurDrive[nCurPan]].Stream +'"');
else
MessageNoStream(aCurDir[nCurPan][aCurDrive[nCurPan]].Stream);
}
}
function OpenInAvailable(nAppType)
{
GetCurFile(nCurPan);
if (nAppType == 4) //open in internally associated
return (aCurWnd[nCurPan] == 0) &&
aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
(! CurFileIsDir(nCurPan)) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].File.indexOf(".") >= 0);
else
return aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
(((aCurWnd[nCurPan] == 0) && (! CurFileIsDir(nCurPan))) ||
((aCurWnd[nCurPan] == 1) && GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], GetCurSelLV(aWnd[IDSTREAMLV0 + nCurPan][HWND]), 1)));
}
function GetInternalAssocIndex()
{
var sExt = aCurDir[nCurPan][aCurDrive[nCurPan]].File.substr(aCurDir[nCurPan][aCurDrive[nCurPan]].File.lastIndexOf(".") + 1);
var i;
while (true)
{
for (i = 0; i < aIntAssoc.length; ++i)
{
if (aIntAssoc[i][0].toUpperCase().indexOf(sExt.toUpperCase()) >= 0)
return i;
}
if (! SetInternalAssoc(-1, 0, sExt))
break;
}
return -1;
}
function Copy(bMove, bOnePan)
{
var nToPan = (bOnePan) ? nCurPan : Number(! nCurPan);
var sTo;
var sPath;
var sName;
var sCaption;
var sFail;
if (! CopyAvailable(bOnePan))
return;
if (aCurWnd[nCurPan] == 0)
{
sName = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
if (CurFileIsDir(nCurPan))
{
sCaption = bMove ? sTxtMovDir : sTxtCopDir;
sTo = sTxtTo;
sPath = aCurDir[nToPan][aCurDrive[nToPan]].Path;
}
else
{
sCaption = bMove ? sTxtMovFile : sTxtCopFile;
if (aCurWnd[nToPan] == 0)
{
sTo = sTxtToFile;
sPath = aCurDir[nToPan][aCurDrive[nToPan]].Path;
}
else
{
sTo = sTxtToStream;
sPath = aCurDir[nToPan][aCurDrive[nToPan]].Path + aCurDir[nToPan][aCurDrive[nToPan]].File + ":";
}
}
}
else
{
sName = aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
sCaption = bMove ? sTxtMovStr : sTxtCopStr;
if (aCurWnd[nToPan] == 0)
{
sTo = sTxtToFile;
sPath = aCurDir[nToPan][aCurDrive[nToPan]].Path;
}
else
{
sTo = sTxtToStream;
sPath = aCurDir[nToPan][aCurDrive[nToPan]].Path + aCurDir[nToPan][aCurDrive[nToPan]].File + ":";
}
}
//Move file to its own stream
if (bMove &&
(aCurWnd[nCurPan] == 0) &&
(aCurWnd[nToPan] == 1) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nToPan][aCurDrive[nToPan]].Path) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nToPan][aCurDrive[nToPan]].File))
{
WarningBox(hWndDlg, sTxtFileToStr, sCaption);
return;
}
sFail = bMove ? sTxtMovFail : sTxtCopFail;
sName = GetFileName(sCaption, sName + "\n\n" + sTo + "\n\n" + sPath, sName);
if (sName)
{
if (! IsDriveExists(aCurDrive[nCurPan]))
{
MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
return;
}
//No source file/dir
if (! GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
{
MessageNoFile(nCurPan, CurFileIsDir(nCurPan));
return;
}
//No source stream
if ((aCurWnd[nCurPan] == 1) &&
(! IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, aCurDir[nCurPan][aCurDrive[nCurPan]].Stream)))
{
MessageNoStream(sName);
return;
}
if (! IsDriveExists(aCurDrive[nToPan]))
{
MessageNoDrive(nToPan, aCurDrive[nToPan]);
return;
}
//No parent of target dir
if (! IsDirExists(aCurDir[nToPan][aCurDrive[nToPan]].Path))
{
MessageNoFile(nToPan, 1, 1);
return;
}
//Copy/move to dir/file
if (aCurWnd[nToPan] == 0)
{
//The same dir/file
if ((aCurWnd[nCurPan] == 0) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].Path == sPath) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].File == sName))
{
if (! bOnePan)
FillFileList(nToPan, sName, 0, 1);
return;
}
//Directory to its own subdirectory
if ((aCurWnd[nCurPan] == 0) && CurFileIsDir(nCurPan) &&
((aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName) == sPath.substr(0, (aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName).length)))
{
WarningBox(hWndDlg, sPath + sName + "\n\n" + sTxtDirToSubdir, sCaption);
return;
}
//Target dir/file already exists
if (GetFileAttr(sPath + sName))
{
if (IsDirExists(sPath + sName))
{
WarningBox(hWndDlg, sPath + sName + "\n\n" + sTxtDirExists, sCaption);
FillFileList(nToPan, sName);
return;
}
if ((aCurWnd[nCurPan] == 0) && CurFileIsDir(nCurPan))
{
WarningBox(hWndDlg, sPath + sName + "\n\n" + sTxtFileExists, sCaption);
FillFileList(nToPan, sName, 0, 1);
return;
}
if (! QuestionBox(hWndDlg, sPath + sName + "\n\n" + sTxtWantReplace, sCaption))
{
FillFileList(nToPan, sName, 0, 1);
return;
}
}
ShowWaitWindow(1);
if (! CopyFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File,
(aCurWnd[nCurPan] == 0) ? 0 : aCurDir[nCurPan][aCurDrive[nCurPan]].Stream,
sPath + sName,
0,
bMove))
{
ShowWaitWindow(0);
WarningBox(hWndDlg, sName + "\n\n" + sFail, sCaption);
}
ShowWaitWindow(0);
if (GetFileAttr(sPath + sName))
{
FillFileList(nToPan, sName, 0, 1);
if ((! bOnePan) && (bMove || (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == sPath)))
RefreshPanel(nCurPan);
}
}
//Copy/move to stream
else if (aCurWnd[nToPan] == 1)
{
//The same stream
if ((aCurWnd[nCurPan] == 1) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nToPan][aCurDrive[nToPan]].Path) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nToPan][aCurDrive[nToPan]].File) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].Stream == sName))
{
if (! bOnePan)
FillStreamList(nToPan, sName);
return;
}
//No target dir/file
if (! GetFileAttr(aCurDir[nToPan][aCurDrive[nToPan]].Path + aCurDir[nToPan][aCurDrive[nToPan]].File))
{
MessageNoFile(nToPan, CurFileIsDir(nToPan));
return;
}
//Target stream already exists
if (IsStreamExists(aCurDir[nToPan][aCurDrive[nToPan]].Path + aCurDir[nToPan][aCurDrive[nToPan]].File, sName))
{
if (! QuestionBox(hWndDlg, sPath + sName + "\n\n" + sTxtWantReplace, sCaption))
{
FillStreamList(nToPan, sName);
return;
}
}
ShowWaitWindow(1);
if (CopyFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File,
(aCurWnd[nCurPan] == 0) ? 0 : aCurDir[nCurPan][aCurDrive[nCurPan]].Stream,
aCurDir[nToPan][aCurDrive[nToPan]].Path + aCurDir[nToPan][aCurDrive[nToPan]].File,
sName,
bMove))
{
ShowWaitWindow(0);
FillStreamList(nToPan, sName);
if (! bOnePan)
{
if (bMove && (aCurWnd[nCurPan] == 0))
{
RefreshPanel(nCurPan);
if (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nToPan][aCurDrive[nToPan]].Path)
RefreshPanel(nToPan);
}
else if (bMove ||
((aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nToPan][aCurDrive[nToPan]].Path) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nToPan][aCurDrive[nToPan]].File)))
RefreshStreamList(nCurPan);
}
}
else
{
ShowWaitWindow(0);
WarningBox(hWndDlg, sName + "\n\n" + sFail, sCaption);
}
}
}
}
function CopyAvailable(bOnePan)
{
var nToPan = (bOnePan) ? nCurPan : Number(! nCurPan);
GetCurFile(nCurPan);
GetCurFile(nToPan);
if (bOnePan)
return aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
(((aCurWnd[nCurPan] == 0) && (aCurDir[nCurPan][aCurDrive[nCurPan]].File != "..")) ||
((aCurWnd[nCurPan] == 1) && aCurDir[nCurPan][aCurDrive[nCurPan]].Stream));
return ! ((! aCurDir[nCurPan][aCurDrive[nCurPan]].File) ||
(aCurDir[nCurPan][aCurDrive[nCurPan]].File == "..") ||
((aCurWnd[nCurPan] == 0) && (aCurWnd[nToPan] == 1) && CurFileIsDir(nCurPan)) ||
((aCurWnd[nCurPan] == 1) && (! aCurDir[nCurPan][aCurDrive[nCurPan]].Stream)) ||
((aCurWnd[nToPan] == 1) && (! IsSupportStreams(aCurDrive[nToPan]))) ||
((aCurWnd[nToPan] == 1) && (! aCurDir[nToPan][aCurDrive[nToPan]].File)) ||
((aCurWnd[nToPan] == 1) && (aCurDir[nToPan][aCurDrive[nToPan]].File == "..")));
}
function Create(bDir)
{
var nPan2 = Number(! nCurPan);
var sName;
var sCaption;
GetCurFile(nCurPan);
GetCurFile(nPan2);
//Create file or directory
if (aCurWnd[nCurPan] == 0)
{
if (bDir)
sCaption = sTxtCreDir;
else
sCaption = sTxtCreFile;
sName = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
if (sName == "..")
sName = "";
sName = GetFileName(sCaption, sTxtInpName, sName);
if (sName)
{
if (! IsDriveExists(aCurDrive[nCurPan]))
{
MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
return;
}
//No parent dir
if (! IsDirExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path))
{
MessageNoFile(nCurPan, 1, 1);
return;
}
//File or directory already exists
if (GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName))
{
if (IsDirExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName))
WarningBox(hWndDlg, sName + "\n\n" + sTxtDirExists, sCaption);
else
WarningBox(hWndDlg, sName + "\n\n" + sTxtFileExists, sCaption);
FillFileList(nCurPan, sName, 0, 1);
}
else
{
if ((bDir && oSys.Call("Kernel32::CreateDirectoryW", aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName, 0)) ||
((! bDir) && CreateFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName)))
{
FillFileList(nCurPan, sName, 0, 1);
if (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path)
RefreshPanel(nPan2);
}
else
WarningBox(hWndDlg, sName + "\n\n" + sTxtCreFail, sCaption);
}
}
}
//Create stream
else
{
if (! CreateStreamAvailable())
return;
sName = GetFileName(sTxtCreStr, sTxtInpName, aCurDir[nCurPan][aCurDrive[nCurPan]].Stream);
if (sName)
{
if (! IsDriveExists(aCurDrive[nCurPan]))
{
MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
return;
}
if (! GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
{
MessageNoFile(nCurPan, CurFileIsDir(nCurPan));
return;
}
if (IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sName))
{
WarningBox(hWndDlg, sName + "\n\n" + sTxtStrExists, sTxtCreStr);
FillStreamList(nCurPan, sName);
}
else
{
if (CreateFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sName))
{
FillStreamList(nCurPan, sName);
if ((aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nPan2][aCurDrive[nPan2]].File))
RefreshStreamList(nPan2);
}
else
WarningBox(hWndDlg, sName + "\n\n" + sTxtCreFail, sTxtCreStr);
}
}
}
}
function CreateStreamAvailable()
{
GetCurFile(nCurPan);
return (aCurWnd[nCurPan] == 1) &&
IsSupportStreams(aCurDrive[nCurPan]) &&
aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].File != "..");
}
function Delete(bRecBin)
{
var nPan2 = Number(! nCurPan);
var sName;
var sCaption;
if (! DeleteAvailable())
return;
GetCurFile(nPan2);
if (aCurWnd[nCurPan] == 0)
{
sName = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
if (CurFileIsDir(nCurPan))
sCaption = bRecBin ? sTxtDelDirToBin : sTxtDelDir;
else
sCaption = bRecBin ? sTxtDelFileToBin : sTxtDelFile;
}
else
{
sName = aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
sCaption = sTxtDelStr;
}
if (QuestionBox(hWndDlg, sName + "\n\n" + sTxtWantDelete, sCaption))
{
if (! IsDriveExists(aCurDrive[nCurPan]))
{
MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
return;
}
if (! GetFileAttr(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File))
{
MessageNoFile(nCurPan, CurFileIsDir(nCurPan));
return;
}
//Delete file or directory
if (aCurWnd[nCurPan] == 0)
{
if (DeleteFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + sName, null, bRecBin))
{
RefreshPanel(nCurPan);
if (aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path)
RefreshPanel(nPan2);
}
else
WarningBox(hWndDlg, sName + "\n\n" + sTxtDelFail, sCaption);
}
//Delete stream
else
{
if (IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sName))
{
if (DeleteFile(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, sName))
{
RefreshStreamList(nCurPan);
if ((aCurDir[nCurPan][aCurDrive[nCurPan]].Path == aCurDir[nPan2][aCurDrive[nPan2]].Path) &&
(aCurDir[nCurPan][aCurDrive[nCurPan]].File == aCurDir[nPan2][aCurDrive[nPan2]].File))
RefreshStreamList(nPan2);
}
else
WarningBox(hWndDlg, sName + "\n\n" + sTxtDelFail, sCaption);
}
else
MessageNoStream(sName);
}
}
}
function DeleteAvailable()
{
GetCurFile(nCurPan);
return aCurDir[nCurPan][aCurDrive[nCurPan]].File &&
(((aCurWnd[nCurPan] == 0) && (aCurDir[nCurPan][aCurDrive[nCurPan]].File != "..")) ||
((aCurWnd[nCurPan] == 1) && aCurDir[nCurPan][aCurDrive[nCurPan]].Stream));
}
function Compare(nAppIndex)
{
var nPan2 = Number(! nCurPan);
var sAppName = ExpandFileName((nAppIndex == 1) ? sComparer : sComparer2);
var sAppPar;
var sFile1;
var sFile2;
if (! CompareAvailable())
return;
if (! IsFileExists(sAppName))
{
if (SetExternalApp(2, nAppIndex, 1))
sAppName = ExpandFileName((nAppIndex == 1) ? sComparer : sComparer2);
else
return;
}
if (! IsDriveExists(aCurDrive[nCurPan]))
{
MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
return;
}
if (! IsDriveExists(aCurDrive[nPan2]))
{
MessageNoDrive(nPan2, aCurDrive[nPan2]);
return;
}
if (aCurDir[nCurPan][aCurDrive[nCurPan]].File == "..")
sFile1 = aCurDir[nCurPan][aCurDrive[nCurPan]].Path.slice(0, -1);
else
sFile1 = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File;
if (! GetFileAttr(sFile1))
{
MessageNoFile(nCurPan, CurFileIsDir(nCurPan), (aCurDir[nCurPan][aCurDrive[nCurPan]].File == ".."));
return;
}
if (aCurWnd[nCurPan] == 1)
{
if (aCurDir[nCurPan][aCurDrive[nCurPan]].Stream)
{
if (IsStreamExists(aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File, aCurDir[nCurPan][aCurDrive[nCurPan]].Stream))
sFile1 = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File + ":" + aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
else
{
MessageNoStream(aCurDir[nCurPan][aCurDrive[nCurPan]].Stream);
return;
}
}
}
if (aCurDir[nPan2][aCurDrive[nPan2]].File == "..")
sFile2 = aCurDir[nPan2][aCurDrive[nPan2]].Path.slice(0, -1);
else
sFile2 = aCurDir[nPan2][aCurDrive[nPan2]].Path + aCurDir[nPan2][aCurDrive[nPan2]].File;
if (! GetFileAttr(sFile2))
{
MessageNoFile(nPan2, CurFileIsDir(nPan2), (aCurDir[nPan2][aCurDrive[nPan2n]].File == ".."));
return;
}
if (aCurWnd[nPan2] == 1)
{
if (aCurDir[nPan2][aCurDrive[nPan2]].Stream)
{
if (IsStreamExists(aCurDir[nPan2][aCurDrive[nPan2]].Path + aCurDir[nPan2][aCurDrive[nPan2]].File, aCurDir[nPan2][aCurDrive[nPan2]].Stream))
sFile2 = aCurDir[nPan2][aCurDrive[nPan2]].Path + aCurDir[nPan2][aCurDrive[nPan2]].File + ":" + aCurDir[nPan2][aCurDrive[nPan2]].Stream;
else
{
MessageNoStream(aCurDir[nPan2][aCurDrive[nPan2]].Stream);
return;
}
}
}
sAppPar = (nAppIndex == 1) ? sComparerPar : sComparerPar2;
AkelPad.Exec(sAppName + ' ' + sAppPar + ' "' + sFile1 + '" "' + sFile2 + '"');
}
function CompareAvailable()
{
var nPan2 = Number(! nCurPan);
GetCurFile(nCurPan);
GetCurFile(nPan2);
return ! ((! aCurDir[nCurPan][aCurDrive[nCurPan]].File) || (! aCurDir[nPan2][aCurDrive[nPan2]].File) ||
((aCurWnd[nCurPan] + aCurWnd[nPan2] == 0) && (CurFileIsDir(nCurPan) != CurFileIsDir(nPan2))) ||
((aCurWnd[nCurPan] == 0) && (aCurWnd[nPan2] == 1) && CurFileIsDir(nCurPan)) ||
((aCurWnd[nCurPan] == 1) && (aCurWnd[nPan2] == 0) && CurFileIsDir(nPan2)) ||
((aCurWnd[nCurPan] == 1) && (! GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], GetCurSelLV(aWnd[IDSTREAMLV0 + nCurPan][HWND]), 1))) ||
((aCurWnd[nPan2] == 1) && (! GetTextLV(aWnd[IDSTREAMLV0 + nPan2][HWND], GetCurSelLV(aWnd[IDSTREAMLV0 + nPan2][HWND]), 1))));
}
function CopyNameToCB(nAction)
{
var sText;
GetCurFile(nCurPan);
if (aCurDir[nCurPan][aCurDrive[nCurPan]].File)
{
if (nAction == 1) //File
sText = aCurDir[nCurPan][aCurDrive[nCurPan]].File;
else if (nAction == 3) //Path\File
sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File;
else if (nAction == 5) //Path\
sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Path;
else if (aCurDir[nCurPan][aCurDrive[nCurPan]].Stream)
{
if (nAction == 4) //Stream
sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
else if (nAction == 6) //Path\File:Stream
sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File + ":" + aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
else if (nAction == 7) //File:Stream
sText = aCurDir[nCurPan][aCurDrive[nCurPan]].File + ":" + aCurDir[nCurPan][aCurDrive[nCurPan]].Stream;
}
if (sText)
AkelPad.SetClipboardText(sText);
}
}
function CopyListToCB(nAction)
{
var nNameLen = 0;
var nTimeLen = 0;
var nFirst = 0;
var sText;
var i;
GetCurFile(nCurPan);
if (aCurDir[nCurPan][aCurDrive[nCurPan]].File)
{
//Files
if (nAction == 0)
{
if (GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], 0, 0) == "..")
nFirst = 1;
if ((bColSize) || (bColTime) || (bColAttr))
{
for (i = nFirst; i < GetItemCountLV(aWnd[IDFILELV0 + nCurPan][HWND]); ++i)
{
if (nNameLen < GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 0).length)
nNameLen = GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 0).length;
if (nTimeLen < GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 2).length)
nTimeLen = GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 2).length;
}
}
if (nFirst < GetItemCountLV(aWnd[IDFILELV0 + nCurPan][HWND]))
sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + "\n";
for (i = nFirst; i < GetItemCountLV(aWnd[IDFILELV0 + nCurPan][HWND]); ++i)
{
sText += Pad(GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 0), nNameLen);
if (bColSize)
sText += Pad(GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 1), 15, "L");
if (bColTime)
sText += Pad(GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 2), nTimeLen + 3, "L");
if (bColAttr)
sText += Pad(GetTextLV(aWnd[IDFILELV0 + nCurPan][HWND], i, 3), 7, "L");
sText += "\n";
}
}
//Steams
else if (IsSupportStreams(aCurDrive[nCurPan]) && (aCurDir[nCurPan][aCurDrive[nCurPan]].File != "..") &&
((! CurFileIsDir(nCurPan)) || aCurDir[nCurPan][aCurDrive[nCurPan]].Stream))
{
if (bColSize)
{
for (i = 0; i < GetItemCountLV(aWnd[IDSTREAMLV0 + nCurPan][HWND]); ++i)
{
if (nNameLen < GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], i, 0).length)
nNameLen = GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], i, 0).length;
}
}
sText = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File + ":" + "\n";
for (i = 0; i < GetItemCountLV(aWnd[IDSTREAMLV0 + nCurPan][HWND]); ++i)
{
sText += Pad(GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], i, 0), nNameLen);
if (bColSize)
sText += Pad(GetTextLV(aWnd[IDSTREAMLV0 + nCurPan][HWND], i, 1), 15, "L");
sText += "\n";
}
}
if (sText)
AkelPad.SetClipboardText(sText);
}
}
function Pad(sString, nLen, sType, sChar)
{
var i = 0;
if (! sType) sType = "R";
if (! sChar) sChar = " ";
if (sType == "R")
{
while (sString.length < nLen)
sString += sChar;
}
else if (sType == "L")
{
while (sString.length < nLen)
sString = sChar + sString;
}
return sString;
}
function Properties()
{
var sFile;
if (! PropertiesAvailable())
return;
if (! IsDriveExists(aCurDrive[nCurPan]))
{
MessageNoDrive(nCurPan, aCurDrive[nCurPan]);
return;
}
if (aCurDir[nCurPan][aCurDrive[nCurPan]].File == "..")
sFile = aCurDir[nCurPan][aCurDrive[nCurPan]].Path.slice(0, -1);
else
sFile = aCurDir[nCurPan][aCurDrive[nCurPan]].Path + aCurDir[nCurPan][aCurDrive[nCurPan]].File;
if (! GetFileAttr(sFile))
{
MessageNoFile(nCurPan, CurFileIsDir(nCurPan), (aCurDir[nCurPan][aCurDrive[nCurPan]].File == ".."));
return;
}
if (! FilePropertiesDialog(sFile, hWndDlg))
WarningBox(hWndDlg, sTxtNoFileProp, sScriptName);
}
function PropertiesAvailable()
{
GetCurFile(nCurPan);
return Boolean(aCurDir[nCurPan][aCurDrive[nCurPan]].File);
}
function FavoriteFolders(nPan)
{
var MF_STRING = 0x0000;
var MF_GRAYED = 0x0001;
var MF_CHECKED = 0x0008;
var MF_POPUP = 0x0010;
var MF_SEPARATOR = 0x0800;
var hMenu01 = oSys.Call("User32::CreatePopupMenu");
var hMenu03 = oSys.Call("User32::CreatePopupMenu");
var hMenu04 = oSys.Call("User32::CreatePopupMenu");
var hMenu = oSys.Call("User32::CreatePopupMenu");
var oRect = {};
var bSet = true;
var nSel = -1;
var nFlag;
var i;
for (i = 0; i < aFavoriteFolder.length; ++i)
{
if (ExpandFileName(aFavoriteFolder[i][1]).toUpperCase() == aCurDir[nPan][aCurDrive[nPan]].Path.toUpperCase())
{
nFlag = MF_CHECKED;
nSel = i;
}
else
nFlag = MF_STRING;
oSys.Call("User32::AppendMenuW", hMenu01, nFlag, 0x0101 + i, aFavoriteFolder[i][0]);
oSys.Call("User32::AppendMenuW", hMenu03, nFlag, 0x0301 + i, aFavoriteFolder[i][0]);
oSys.Call("User32::AppendMenuW", hMenu04, nFlag, 0x0401 + i, aFavoriteFolder[i][0]);
}
oSys.Call("User32::AppendMenuW", hMenu, aFavoriteFolder.length ? MF_POPUP : MF_GRAYED, hMenu01, sTxtGoToFavFold);
oSys.Call("User32::AppendMenuW", hMenu, MF_SEPARATOR, 0);
oSys.Call("User32::AppendMenuW", hMenu, (aFavoriteFolder.length < 0xFF) ? MF_STRING : MF_GRAYED, 0x0200, sTxtAddFavorite);
oSys.Call("User32::AppendMenuW", hMenu, aFavoriteFolder.length ? MF_POPUP : MF_GRAYED, hMenu03, sTxtModFavorite);
oSys.Call("User32::AppendMenuW", hMenu, aFavoriteFolder.length ? MF_POPUP : MF_GRAYED, hMenu04, sTxtDelFavorite);
oSys.Call("User32::AppendMenuW", hMenu, aFavoriteFolder.length ? MF_STRING : MF_GRAYED, 0x0500, sTxtCleFavorite);
GetWindowPos(aWnd[IDFAVFOLDB0 + nPan][HWND], oRect);
nCmd = oSys.Call("User32::TrackPopupMenu", hMenu, 0x0180 /*TPM_NONOTIFY|TPM_RETURNCMD*/, oRect.X + oRect.W, oRect.Y, 0, hWndDlg, 0);
oSys.Call("User32::DestroyMenu", hMenu01);
oSys.Call("User32::DestroyMenu", hMenu03);
oSys.Call("User32::DestroyMenu", hMenu04);
oSys.Call("User32::DestroyMenu", hMenu);
if ((nCmd >= 0x0101) && (nCmd <= 0x01FF))
{
if (nCmd - 0x0101 != nSel)
{
if (! IsDirExists(ExpandFileName(aFavoriteFolder[nCmd - 0x0101][1])))
bSet = SetFavoriteFolder(nPan, nCmd - 0x0101, 1);
if (bSet)
ChangeDir(nPan, aFavoriteFolder[nCmd - 0x0101][1]);
}
}
else if (nCmd == 0x0200)
SetFavoriteFolder(nPan, -1); //add favorite
else if ((nCmd >= 0x0301) && (nCmd <= 0x03FF))
SetFavoriteFolder(nPan, nCmd - 0x0301); //modify favorite
else if ((nCmd >= 0x0401) && (nCmd <= 0x04FF))
RemoveFavoriteFolder(nCmd - 0x0401);
else if (nCmd == 0x0500)
{
if (QuestionBox(hWndDlg, sTxtWantCleFavFo, sTxtDirectory + ": " + sTxtCleFavorite, 1))
aFavoriteFolder = [];
}
}
function SetFavoriteFolder(nPan, nIndex, nFocus)
{
var bSet = false;
var sCaption = sTxtDirectory + ": ";
var aDir = new Array(2);
if (nIndex < 0) //add favorite
{
sCaption += sTxtAddFavorite;
aDir[1] = aCurDir[nPan][aCurDrive[nPan]].Path;
aDir[0] = aDir[1].slice(0, -1);
aDir[0] = ((aDir[0].length > 2) ? aDir[0].substr(0, 2) : "") + aDir[0].substr(aDir[0].lastIndexOf("\\") + 1);
}
else //modify favorite
{
sCaption += sTxtModFavorite;
aDir = aFavoriteFolder[nIndex];
}
aDir = InputBox(hWndDlg, sCaption, [sTxtDispName + ":", sTxtPath + " (%a - " + sTxtAkelDir + ", %WinDir% - " + sTxtEnvVar + "):"], aDir, nFocus, "CheckInputPath", nIndex);
if (aDir)
{
if (aDir[1].slice(-1) != "\\")
aDir[1] += "\\";
if (nIndex < 0)
aFavoriteFolder.push([aDir[0], aDir[1]]);
else
aFavoriteFolder[nIndex] = [aDir[0], aDir[1]];
aFavoriteFolder.sort(
function(aA, aB)
{
return oSys.Call("Kernel32::lstrcmpiW", aA[0], aB[0]);
});
bSet = true;
}
return bSet;
}
function CheckInputPath(hWnd, aDir, nIndex)
{
var sPath;
if (! aDir[0])
{
WarningBox(hWnd, sTxtMustSpecify + ": " + sTxtDispName, sScriptName);
return 0;
}
if (IsNameInArray(aFavoriteFolder, aDir[0], nIndex))
{
WarningBox(hWnd, aDir[0] + "\n\n" + sTxtNameExists, sScriptName);
return 0;
}
if (! aDir[1])
{
WarningBox(hWnd, sTxtMustSpecify + ": " + sTxtPath, sScriptName);
return 1;
}
sPath = ExpandFileName(aDir[1] + ((aDir[1].slice(-1) != "\\") ? "\\" : ""));
if (! IsDirExists(sPath))
{
WarningBox(hWnd, sPath + "\n\n" + sTxtDirNoExists, sScriptName);
return 1;
}
return -1;
}
function IsNameInArray(aArray, sName, nIndex)
{
for (var i = 0; i < aArray.length; ++i)
{
if ((aArray[i][0] == sName) && (i != nIndex))
return true;
}
return false;
}
function RemoveFavoriteFolder(nIndex)
{
if (QuestionBox(hWndDlg, aFavoriteFolder[nIndex][0] + "\n" + aFavoriteFolder[nIndex][1] + "\n\n" + sTxtWantDelFav, sTxtDirectory + ": " + sTxtDelFavorite))
aFavoriteFolder.splice(nIndex, 1);
}
function SpecialFolders(nPan)
{
var aFolder = [];
var oRect = {};
var hMenu = oSys.Call("User32::CreatePopupMenu");
var nSel = -1;
var nFlag;
var nCmd;
var i;
for (i = 0; i < 63; ++i)
{
if (oSys.Call("Shell32::SHGetSpecialFolderPathW", 0, lpBuffer, i, 0))
aFolder.push(AkelPad.MemRead(lpBuffer, _TSTR) + "\\");
}
aFolder.sort(function(sA, sB)
{
return oSys.Call("Kernel32::lstrcmpiW", sA, sB);
} );
for (i = 0; i < aFolder.length; ++i)
{
if ((i == 0) || (aFolder[i] != aFolder[i - 1]))
{
if (aFolder[i].toUpperCase() == aCurDir[nPan][aCurDrive[nPan]].Path.toUpperCase())
{
nFlag = 0x0008; //MF_CHECKED
nSel = i;
}
else
nFlag = 0x0000; //MF_STRING
oSys.Call("User32::AppendMenuW", hMenu, nFlag, i + 1, aFolder[i]);
}
}
GetWindowPos(aWnd[IDSPECFOLDB0 + nPan][HWND], oRect);
nFlag = 0x0180; //TPM_RETURNCMD|TPM_NONOTIFY
if (nPan == 0)
oRect.X += oRect.W;
else
nFlag |= 0x0008; //TPM_RIGHTALIGN
nCmd = oSys.Call("User32::TrackPopupMenu", hMenu, nFlag, oRect.X, oRect.Y, 0, hWndDlg, 0);
oSys.Call("User32::DestroyMenu", hMenu);
if (nCmd && (--nCmd != nSel))
{
if (IsDirExists(aFolder[nCmd]))
ChangeDir(nPan, aFolder[nCmd]);
else
WarningBox(hWndDlg, aFolder[nCmd] + "\n\n" + sTxtDirNoExists, sScriptName);
}
}
function History(nPan)
{
var MF_STRING = 0x0000;
var MF_GRAYED = 0x0001;
var MF_CHECKED = 0x0008;
var MF_SEPARATOR = 0x0800;
var hMenu = oSys.Call("User32::CreatePopupMenu");
var nFlag = 0x0180; //TPM_RETURNCMD|TPM_NONOTIFY
var oRect = {};
var i;
GetWindowPos(aWnd[IDHISTORYB0 + nPan][HWND], oRect);
if (nPan == 0)
oRect.X += oRect.W;
else
nFlag |= 0x0008; //TPM_RIGHTALIGN
for (i = aHistory[nPan].length - 1; i >= 0; --i)
{
if ((i != aCurHist[nPan]) && (! IsDirExists(aHistory[nPan][i][0])))
{
aHistory[nPan].splice(i, 1);
if (i < aCurHist[nPan])
--aCurHist[nPan];
}
}
for (i = 0; i < aHistory[nPan].length; ++i)
oSys.Call("User32::AppendMenuW", hMenu, (i == aCurHist[nPan]) ? MF_CHECKED : MF_STRING, i + 1, aHistory[nPan][i][0]);
oSys.Call("User32::AppendMenuW", hMenu, MF_SEPARATOR, 0);
oSys.Call("User32::AppendMenuW", hMenu, (aHistory.length > 1) ? MF_STRING : MF_GRAYED, nHistMax + 1, sTxtCleHistory);
oSys.Call("User32::AppendMenuW", hMenu, bSaveHist ? MF_CHECKED : MF_STRING, nHistMax + 2, sTxtSaveHistory);
nCmd = oSys.Call("User32::TrackPopupMenu", hMenu, nFlag, oRect.X, oRect.Y, 0, hWndDlg, 0);
oSys.Call("User32::DestroyMenu", hMenu);
if ((nCmd > 0) && (nCmd <= nHistMax))
{
if (--nCmd != aCurHist[nPan])
{
if (IsDirExists(aHistory[nPan][nCmd][0]))
ChangeDirFromHistory(nPan, nCmd);
else
WarningBox(hWndDlg, aHistory[nPan][nCmd][0] + "\n\n" + sTxtDirNoExists, sScriptName);
}
}
else if (nCmd == nHistMax + 1)
{
aCurHist[nPan] = 0;
aHistory[nPan] = [[aCurDir[nPan][aCurDrive[nPan]].Path, "", ""]];
}
else if (nCmd == nHistMax + 2)
bSaveHist = ! bSaveHist;
}