string& __stdcall TruncStr(string &strStr, int MaxLength) { wchar_t *lpwszBuffer = strStr.GetBuffer(); TruncStr(lpwszBuffer, MaxLength); strStr.ReleaseBuffer(); return strStr; }
string Panel::GetTitleForDisplay() const { auto Title = concat(L' ', GetTitle()); TruncStr(Title, m_X2 - m_X1 - 2); Title += L' '; return Title; }
void FileList::ShowSelectedSize() { if (Opt.ShowPanelStatus) { SetColor(COL_PANELBOX); DrawSeparator(Y2-2); for (int I=0,ColumnPos=X1+1; I<ViewSettings.ColumnCount-1; I++) { if (ViewSettings.ColumnWidth[I]<0 || (I==ViewSettings.ColumnCount-2 && ViewSettings.ColumnWidth[I+1]<0)) continue; ColumnPos+=ViewSettings.ColumnWidth[I]; GotoXY(ColumnPos,Y2-2); bool DoubleLine = Opt.DoubleGlobalColumnSeparator && (!((I+1)%ColumnsInGlobal)); BoxText(BoxSymbols[DoubleLine?BS_B_H1V2:BS_B_H1V1]); ColumnPos++; } } if (SelFileCount) { string strFormStr; InsertCommas(SelFileSize,strFormStr); LangString strSelStr(__FormatEndSelectedPhrase(SelFileCount)); strSelStr << strFormStr << SelFileCount; TruncStr(strSelStr,X2-X1-1); int Length=(int)strSelStr.GetLength(); SetColor(COL_PANELSELECTEDINFO); GotoXY(X1+(X2-X1+1-Length)/2,Y2-2*Opt.ShowPanelStatus); Text(strSelStr); } }
string QuickView::GetTitle() const { string strTitle = L" "; strTitle+=MSG(MQuickViewTitle); strTitle+=L" "; TruncStr(strTitle,m_X2-m_X1-3); return strTitle; }
FARString &QuickView::GetTitle(FARString &strTitle,int SubLen,int TruncSize) { strTitle=L" "; strTitle+=MSG(MQuickViewTitle); strTitle+=L" "; TruncStr(strTitle,X2-X1-3); return strTitle; }
wchar_t* WINAPI TruncPathStr(wchar_t *Str, int MaxLength) { assert(MaxLength >= 0); MaxLength=Max(0, MaxLength); if (Str) { int nLength = (int)wcslen(Str); if ((MaxLength > 0) && (nLength > MaxLength) && (nLength >= 2)) { wchar_t *lpStart = nullptr; if (*Str && (Str[1] == L':') && IsSlash(Str[2])) lpStart = Str+3; else { if ((Str[0] == L'\\') && (Str[1] == L'\\')) { if ((lpStart = const_cast<wchar_t*>(FirstSlash(Str+2))) ) { wchar_t *lpStart2=lpStart; if ((lpStart-Str < nLength) && ((lpStart=const_cast<wchar_t*>(FirstSlash(lpStart2+1))))) lpStart++; } } } if (!lpStart || (lpStart-Str > MaxLength-5)) return TruncStr(Str, MaxLength); wchar_t *lpInPos = lpStart+3+(nLength-MaxLength); wmemmove(lpStart+3, lpInPos, (wcslen(lpInPos)+1)); wmemcpy(lpStart, L"...", 3); } } return Str; }
char *TruncPathStr (char *Str, int MaxLength) { if(Str) { char *Root=NULL; if (Str[0]!=0 && Str[1]==':' && Str[2]=='\\') Root=Str+3; else if (Str[0]=='\\' && Str[1]=='\\' && (Root=strchr(Str+2,'\\'))!=NULL && (Root=strchr(Root+1,'\\'))!=NULL) Root++; if (Root==NULL || Root-Str+5>MaxLength) return(TruncStr(Str,MaxLength)); int Length=strlen(Str); if (Length>MaxLength) { char *MovePos=Root+Length-MaxLength+3; memmove (Root+3,MovePos,strlen(MovePos)+1); memcpy (Root,"...",3); } } return(Str); }
void QuickView::DisplayObject() { if (m_Flags.Check(FSCROBJ_ISREDRAWING)) return; m_Flags.Set(FSCROBJ_ISREDRAWING); if (!QView && !ProcessingPluginCommand) Parent()->GetAnotherPanel(this)->UpdateViewPanel(); if (this->Destroyed()) return; if (QView) QView->SetPosition(m_X1+1,m_Y1+1,m_X2-1,m_Y2-3); Box(m_X1,m_Y1,m_X2,m_Y2,colors::PaletteColorToFarColor(COL_PANELBOX),DOUBLE_BOX); SetScreen(m_X1+1,m_Y1+1,m_X2-1,m_Y2-1,L' ',colors::PaletteColorToFarColor(COL_PANELTEXT)); SetColor(m_Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE); string strTitle = GetTitle(); if (!strTitle.empty()) { GotoXY(m_X1+(m_X2-m_X1+1-(int)strTitle.size())/2,m_Y1); Text(strTitle); } DrawSeparator(m_Y2-2); SetColor(COL_PANELTEXT); GotoXY(m_X1+1,m_Y2-1); Global->FS << fmt::LeftAlign()<<fmt::ExactWidth(m_X2-m_X1-1)<<PointToName(strCurFileName); if (!strCurFileType.empty()) { string strTypeText=L" "; strTypeText+=strCurFileType; strTypeText+=L" "; TruncStr(strTypeText,m_X2-m_X1-1); SetColor(COL_PANELSELECTEDINFO); GotoXY(m_X1+(m_X2-m_X1+1-(int)strTypeText.size())/2,m_Y2-2); Text(strTypeText); } if (Directory) { FormatString FString; string DisplayName(strCurFileName); TruncPathStr(DisplayName,std::max(0, m_X2-m_X1-1-StrLength(MSG(MQuickViewFolder))-5)); FString<<MSG(MQuickViewFolder)<<L" \""<<DisplayName<<L"\""; SetColor(COL_PANELTEXT); GotoXY(m_X1+2,m_Y1+2); PrintText(FString); DWORD currAttr=os::GetFileAttributes(strCurFileName); // обламывается, если нет доступа if (currAttr != INVALID_FILE_ATTRIBUTES && (currAttr&FILE_ATTRIBUTE_REPARSE_POINT)) { string Tmp, Target; DWORD ReparseTag=0; const wchar_t* PtrName; if (GetReparsePointInfo(strCurFileName, Target, &ReparseTag)) { NormalizeSymlinkName(Target); switch(ReparseTag) { // 0xA0000003L = Directory Junction or Volume Mount Point case IO_REPARSE_TAG_MOUNT_POINT: { LNGID ID_Msg = MQuickViewJunction; bool Root; if(ParsePath(Target, nullptr, &Root) == PATH_VOLUMEGUID && Root) { ID_Msg=MQuickViewVolMount; } PtrName = MSG(ID_Msg); } break; // 0xA000000CL = Directory or File Symbolic Link case IO_REPARSE_TAG_SYMLINK: PtrName = MSG(MQuickViewSymlink); break; // 0x8000000AL = Distributed File System case IO_REPARSE_TAG_DFS: PtrName = MSG(MQuickViewDFS); break; // 0x80000012L = Distributed File System Replication case IO_REPARSE_TAG_DFSR: PtrName = MSG(MQuickViewDFSR); break; // 0xC0000004L = Hierarchical Storage Management case IO_REPARSE_TAG_HSM: PtrName = MSG(MQuickViewHSM); break; // 0x80000006L = Hierarchical Storage Management2 case IO_REPARSE_TAG_HSM2: PtrName = MSG(MQuickViewHSM2); break; // 0x80000007L = Single Instance Storage case IO_REPARSE_TAG_SIS: PtrName = MSG(MQuickViewSIS); break; // 0x80000008L = Windows Imaging Format case IO_REPARSE_TAG_WIM: PtrName = MSG(MQuickViewWIM); break; // 0x80000009L = Cluster Shared Volumes case IO_REPARSE_TAG_CSV: PtrName = MSG(MQuickViewCSV); break; case IO_REPARSE_TAG_DEDUP: PtrName = MSG(MQuickViewDEDUP); break; case IO_REPARSE_TAG_NFS: PtrName = MSG(MQuickViewNFS); break; case IO_REPARSE_TAG_FILE_PLACEHOLDER: PtrName = MSG(MQuickViewPlaceholder); break; // 0x????????L = anything else default: if (Global->Opt->ShowUnknownReparsePoint) { Tmp = FormatString() << L":" << fmt::Radix(16) << fmt::ExactWidth(8) << fmt::FillChar(L'0') << ReparseTag; PtrName = Tmp.data(); } else { PtrName=MSG(MQuickViewUnknownReparsePoint); } } } else { PtrName = MSG(MQuickViewUnknownReparsePoint); Target = MSG(MQuickViewNoData); } TruncPathStr(Target,std::max(0, m_X2-m_X1-1-StrLength(PtrName)-5)); FString.clear(); FString<<PtrName<<L" \""<<Target<<L"\""; SetColor(COL_PANELTEXT); GotoXY(m_X1+2,m_Y1+3); PrintText(FString); } if (Directory==1 || Directory==4) { const auto iColor = uncomplete_dirscan? COL_PANELHIGHLIGHTTEXT : COL_PANELINFOTEXT; const wchar_t *prefix = uncomplete_dirscan ? L"~" : L""; GotoXY(m_X1+2,m_Y1+4); PrintText(MSG(MQuickViewContains)); GotoXY(m_X1+2,m_Y1+6); PrintText(MSG(MQuickViewFolders)); SetColor(iColor); FString.clear(); FString<<prefix<<Data.DirCount; PrintText(FString); SetColor(COL_PANELTEXT); GotoXY(m_X1+2,m_Y1+7); PrintText(MSG(MQuickViewFiles)); SetColor(iColor); FString.clear(); FString<<prefix<<Data.FileCount; PrintText(FString); SetColor(COL_PANELTEXT); GotoXY(m_X1+2,m_Y1+8); PrintText(MSG(MQuickViewBytes)); SetColor(iColor); string strSize; InsertCommas(Data.FileSize,strSize); PrintText(prefix+strSize); SetColor(COL_PANELTEXT); GotoXY(m_X1+2,m_Y1+9); PrintText(MSG(MQuickViewAllocated)); SetColor(iColor); InsertCommas(Data.AllocationSize,strSize); FString.clear(); FString << prefix << strSize << L" (" << ToPercent(Data.AllocationSize,Data.FileSize) << L"%)"; PrintText(FString); if (Directory!=4) { SetColor(COL_PANELTEXT); GotoXY(m_X1+2,m_Y1+11); PrintText(MSG(MQuickViewCluster)); SetColor(iColor); InsertCommas(Data.ClusterSize,strSize); PrintText(prefix+strSize); SetColor(COL_PANELTEXT); GotoXY(m_X1+2,m_Y1+12); PrintText(MSG(MQuickViewSlack)); SetColor(iColor); InsertCommas(Data.FilesSlack, strSize); FString.clear(); FString << prefix << strSize << L" (" << ToPercent(Data.FilesSlack, Data.AllocationSize) << L"%)"; PrintText(FString); SetColor(COL_PANELTEXT); GotoXY(m_X1+2,m_Y1+13); PrintText(MSG(MQuickViewMFTOverhead)); SetColor(iColor); InsertCommas(Data.MFTOverhead, strSize); FString.clear(); FString<<prefix<<strSize<<L" ("<<ToPercent(Data.MFTOverhead, Data.AllocationSize)<<L"%)"; PrintText(FString); } } } else if (QView) QView->Show(); m_Flags.Clear(FSCROBJ_ISREDRAWING); }
void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessage) { TPreRedrawFuncGuard preRedrawFuncGuard(PR_ReadFileNamesMsg); TaskBar TB(false); strOriginalCurDir=strCurDir; if (!IsVisible() && !IgnoreVisible) { UpdateRequired=TRUE; UpdateRequiredMode=KeepSelection; return; } UpdateRequired=FALSE; AccessTimeUpdateRequired=FALSE; DizRead=FALSE; FAR_FIND_DATA_EX fdata; FileListItem *CurPtr=0,**OldData=0; string strCurName, strNextCurName; int OldFileCount=0; StopFSWatcher(); if (this!=CtrlObject->Cp()->LeftPanel && this!=CtrlObject->Cp()->RightPanel) return; string strSaveDir; apiGetCurrentDirectory(strSaveDir); { string strOldCurDir = strCurDir; if (!SetCurPath()) { FlushInputBuffer(); // Очистим буффер ввода, т.к. мы уже можем быть в другом месте... if (!StrCmp(strCurDir, strOldCurDir)) //?? i?? { GetPathRoot(strOldCurDir,strOldCurDir); if (!apiIsDiskInDrive(strOldCurDir)) IfGoHome(strOldCurDir.At(0)); /* При смене каталога путь не изменился */ } return; } } SortGroupsRead=FALSE; if (GetFocus()) CtrlObject->CmdLine->SetCurDir(strCurDir); LastCurFile=-1; Panel *AnotherPanel=CtrlObject->Cp()->GetAnotherPanel(this); AnotherPanel->QViewDelTempName(); size_t PrevSelFileCount=SelFileCount; SelFileCount=0; SelFileSize=0; TotalFileCount=0; TotalFileSize=0; CacheSelIndex=-1; CacheSelClearIndex=-1; if (Opt.ShowPanelFree) { unsigned __int64 TotalSize,TotalFree; if (!apiGetDiskSize(strCurDir,&TotalSize,&TotalFree,&FreeDiskSize)) FreeDiskSize=0; } if (FileCount>0) { strCurName = ListData[CurFile]->strName; if (ListData[CurFile]->Selected) { for (int i=CurFile+1; i < FileCount; i++) { CurPtr = ListData[i]; if (!CurPtr->Selected) { strNextCurName = CurPtr->strName; break; } } } } if (KeepSelection || PrevSelFileCount>0) { OldData=ListData; OldFileCount=FileCount; } else DeleteListData(ListData,FileCount); ListData=nullptr; int ReadOwners=IsColumnDisplayed(OWNER_COLUMN); int ReadNumLinks=IsColumnDisplayed(NUMLINK_COLUMN); int ReadNumStreams=IsColumnDisplayed(NUMSTREAMS_COLUMN); int ReadStreamsSize=IsColumnDisplayed(STREAMSSIZE_COLUMN); string strComputerName; if (ReadOwners) { CurPath2ComputerName(strCurDir, strComputerName); // сбросим кэш SID`ов SIDCacheFlush(); } SetLastError(ERROR_SUCCESS); int AllocatedCount=0; FileListItem *NewPtr; // сформируем заголовок вне цикла wchar_t Title[2048]; int TitleLength=Min((int)X2-X1-1,(int)(ARRAYSIZE(Title))-1); //wmemset(Title,0x0CD,TitleLength); //BUGBUG //Title[TitleLength]=0; MakeSeparator(TitleLength, Title, 9, nullptr); BOOL IsShowTitle=FALSE; BOOL NeedHighlight=Opt.Highlight && PanelMode != PLUGIN_PANEL; if (!Filter) Filter=new FileFilter(this,FFT_PANEL); //Рефреш текущему времени для фильтра перед началом операции Filter->UpdateCurrentTime(); CtrlObject->HiFiles->UpdateCurrentTime(); bool bCurDirRoot = false; ParsePath(strCurDir, nullptr, &bCurDirRoot); PATH_TYPE Type = ParsePath(strCurDir, nullptr, &bCurDirRoot); bool NetRoot = bCurDirRoot && (Type == PATH_REMOTE || Type == PATH_REMOTEUNC); FileCount = 0; string strFind = strCurDir; AddEndSlash(strFind); strFind+=L'*'; ::FindFile Find(strFind, true); DWORD FindErrorCode = ERROR_SUCCESS; bool UseFilter=Filter->IsEnabledOnPanel(); bool ReadCustomData=IsColumnDisplayed(CUSTOM_COLUMN0)!=0; DWORD StartTime = GetTickCount(); while (Find.Get(fdata)) { FindErrorCode = GetLastError(); if ((Opt.ShowHidden || !(fdata.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))) && (!UseFilter || Filter->FileInFilter(fdata, nullptr, &fdata.strFileName))) { if (FileCount>=AllocatedCount) { AllocatedCount+=4096; FileListItem **pTemp; if (!(pTemp=(FileListItem **)xf_realloc(ListData,AllocatedCount*sizeof(*ListData)))) break; ListData=pTemp; } ListData[FileCount] = new FileListItem; ListData[FileCount]->Clear(); NewPtr=ListData[FileCount]; NewPtr->FileAttr = fdata.dwFileAttributes; NewPtr->CreationTime = fdata.ftCreationTime; NewPtr->AccessTime = fdata.ftLastAccessTime; NewPtr->WriteTime = fdata.ftLastWriteTime; NewPtr->ChangeTime = fdata.ftChangeTime; NewPtr->FileSize = fdata.nFileSize; NewPtr->AllocationSize = fdata.nAllocationSize; NewPtr->strName = fdata.strFileName; NewPtr->strShortName = fdata.strAlternateFileName; NewPtr->Position=FileCount++; NewPtr->NumberOfLinks=1; if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { NewPtr->ReparseTag=fdata.dwReserved0; //MSDN } if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { TotalFileSize += NewPtr->FileSize; if (ReadNumLinks) NewPtr->NumberOfLinks=GetNumberOfLinks(fdata.strFileName); } else { NewPtr->AllocationSize = 0; } NewPtr->SortGroup=DEFAULT_SORT_GROUP; if (ReadOwners) { string strOwner; GetFileOwner(strComputerName, NewPtr->strName,strOwner); NewPtr->strOwner = strOwner; } NewPtr->NumberOfStreams=NewPtr->FileAttr&FILE_ATTRIBUTE_DIRECTORY?0:1; NewPtr->StreamsSize=NewPtr->FileSize; if (ReadNumStreams||ReadStreamsSize) { EnumStreams(TestParentFolderName(fdata.strFileName)?strCurDir:fdata.strFileName,NewPtr->StreamsSize,NewPtr->NumberOfStreams); } if (ReadCustomData) CtrlObject->Plugins->GetCustomData(NewPtr); if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) TotalFileCount++; //memcpy(ListData+FileCount,&NewPtr,sizeof(NewPtr)); // FileCount++; DWORD CurTime = GetTickCount(); if (CurTime - StartTime > RedrawTimeout) { StartTime = CurTime; if (IsVisible()) { if (!IsShowTitle) { if (!DrawMessage) { Text(X1+1,Y1,ColorIndexToColor(COL_PANELBOX),Title); IsShowTitle=TRUE; SetColor(Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE); } } LangString strReadMsg(MReadingFiles); strReadMsg << FileCount; if (DrawMessage) { ReadFileNamesMsg(strReadMsg); } else { TruncStr(strReadMsg,TitleLength-2); int MsgLength=(int)strReadMsg.GetLength(); GotoXY(X1+1+(TitleLength-MsgLength-1)/2,Y1); FS<<L" "<<strReadMsg<<L" "; } } if (CheckForEsc()) { break; } } } } if (!(FindErrorCode==ERROR_SUCCESS || FindErrorCode==ERROR_NO_MORE_FILES || FindErrorCode==ERROR_FILE_NOT_FOUND)) Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MError),MSG(MReadFolderError),MSG(MOk)); if ((Opt.ShowDotsInRoot || !bCurDirRoot) || (NetRoot && CtrlObject->Plugins->FindPlugin(Opt.KnownIDs.Network))) // NetWork Plugin { if (FileCount>=AllocatedCount) { FileListItem **pTemp; if ((pTemp=(FileListItem **)xf_realloc(ListData,(FileCount+1)*sizeof(*ListData)))) ListData=pTemp; } if (ListData) { ListData[FileCount] = new FileListItem; string TwoDotsOwner; if (ReadOwners) { GetFileOwner(strComputerName,strCurDir,TwoDotsOwner); } FILETIME TwoDotsTimes[4]={}; if(apiGetFindDataEx(strCurDir,fdata)) { TwoDotsTimes[0]=fdata.ftCreationTime; TwoDotsTimes[1]=fdata.ftLastAccessTime; TwoDotsTimes[2]=fdata.ftLastWriteTime; TwoDotsTimes[3]=fdata.ftChangeTime; } AddParentPoint(ListData[FileCount],FileCount,TwoDotsTimes,TwoDotsOwner); FileCount++; } } if (IsColumnDisplayed(DIZ_COLUMN)) ReadDiz(); if (NeedHighlight) { CtrlObject->HiFiles->GetHiColor(ListData, FileCount); } if (AnotherPanel->GetMode()==PLUGIN_PANEL) { HANDLE hAnotherPlugin=AnotherPanel->GetPluginHandle(); PluginPanelItem *PanelData=nullptr; string strPath; size_t PanelCount=0; strPath = strCurDir; AddEndSlash(strPath); if (CtrlObject->Plugins->GetVirtualFindData(hAnotherPlugin,&PanelData,&PanelCount,strPath)) { FileListItem **pTemp; if ((pTemp=(FileListItem **)xf_realloc(ListData,(FileCount+PanelCount)*sizeof(*ListData)))) { ListData=pTemp; for (size_t i=0; i < PanelCount; i++) { CurPtr = ListData[FileCount+i]; PluginPanelItem &pfdata=PanelData[i]; PluginToFileListItem(&PanelData[i],CurPtr); CurPtr->Position=FileCount; TotalFileSize += pfdata.FileSize; CurPtr->PrevSelected=CurPtr->Selected=0; CurPtr->ShowFolderSize=0; CurPtr->SortGroup=CtrlObject->HiFiles->GetGroup(CurPtr); if (!TestParentFolderName(pfdata.FileName) && !(CurPtr->FileAttr & FILE_ATTRIBUTE_DIRECTORY)) TotalFileCount++; } // цветовую боевую раскраску в самом конце, за один раз CtrlObject->HiFiles->GetHiColor(&ListData[FileCount],PanelCount); FileCount+=static_cast<int>(PanelCount); } CtrlObject->Plugins->FreeVirtualFindData(hAnotherPlugin,PanelData,PanelCount); } } InitFSWatcher(false); CorrectPosition(); if (KeepSelection || PrevSelFileCount>0) { MoveSelection(ListData,FileCount,OldData,OldFileCount); DeleteListData(OldData,OldFileCount); } if (SortGroups) ReadSortGroups(false); if (!KeepSelection && PrevSelFileCount>0) { SaveSelection(); ClearSelection(); } SortFileList(FALSE); if (CurFile>=FileCount || StrCmpI(ListData[CurFile]->strName,strCurName)) if (!GoToFile(strCurName) && !strNextCurName.IsEmpty()) GoToFile(strNextCurName); /* $ 13.02.2002 DJ SetTitle() - только если мы текущий фрейм! */ if (CtrlObject->Cp() == FrameManager->GetCurrentFrame()) SetTitle(); FarChDir(strSaveDir); //??? }
void FileList::ReadFileNames(int KeepSelection, int UpdateEvenIfPanelInvisible, int DrawMessage) { SCOPED_ACTION(TPreRedrawFuncGuard)(std::make_unique<FileListPreRedrawItem>()); SCOPED_ACTION(TaskBar)(false); strOriginalCurDir = strCurDir; if (!IsVisible() && !UpdateEvenIfPanelInvisible) { UpdateRequired=TRUE; UpdateRequiredMode=KeepSelection; return; } UpdateRequired=FALSE; AccessTimeUpdateRequired=FALSE; DizRead=FALSE; api::FAR_FIND_DATA fdata; decltype(ListData) OldData; string strCurName, strNextCurName; StopFSWatcher(); if (this!=Global->CtrlObject->Cp()->LeftPanel && this!=Global->CtrlObject->Cp()->RightPanel) return; string strSaveDir; api::GetCurrentDirectory(strSaveDir); { string strOldCurDir(strCurDir); if (!SetCurPath()) { FlushInputBuffer(); // Очистим буффер ввода, т.к. мы уже можем быть в другом месте... if (strCurDir == strOldCurDir) //?? i?? { GetPathRoot(strOldCurDir,strOldCurDir); if (!api::IsDiskInDrive(strOldCurDir)) IfGoHome(strOldCurDir.front()); /* При смене каталога путь не изменился */ } return; } } SortGroupsRead=FALSE; if (GetFocus()) Global->CtrlObject->CmdLine->SetCurDir(strCurDir); LastCurFile=-1; Panel *AnotherPanel=Global->CtrlObject->Cp()->GetAnotherPanel(this); AnotherPanel->QViewDelTempName(); size_t PrevSelFileCount=SelFileCount; SelFileCount=0; SelFileSize=0; TotalFileCount=0; TotalFileSize=0; CacheSelIndex=-1; CacheSelClearIndex=-1; FreeDiskSize = -1; if (Global->Opt->ShowPanelFree) { api::GetDiskSize(strCurDir, nullptr, nullptr, &FreeDiskSize); } if (!ListData.empty()) { strCurName = ListData[CurFile].strName; if (ListData[CurFile].Selected && !ReturnCurrentFile) { for (size_t i=CurFile+1; i < ListData.size(); i++) { if (!ListData[i].Selected) { strNextCurName = ListData[i].strName; break; } } } } if (KeepSelection || PrevSelFileCount>0) { OldData.swap(ListData); } else DeleteListData(ListData); DWORD FileSystemFlags = 0; string PathRoot; GetPathRoot(strCurDir, PathRoot); api::GetVolumeInformation(PathRoot, nullptr, nullptr, nullptr, &FileSystemFlags, nullptr); ListData.clear(); bool ReadOwners = IsColumnDisplayed(OWNER_COLUMN); bool ReadNumLinks = IsColumnDisplayed(NUMLINK_COLUMN); bool ReadNumStreams = IsColumnDisplayed(NUMSTREAMS_COLUMN); bool ReadStreamsSize = IsColumnDisplayed(STREAMSSIZE_COLUMN); if (!(FileSystemFlags&FILE_SUPPORTS_HARD_LINKS) && IsWindows7OrGreater()) { ReadNumLinks = false; } if(!(FileSystemFlags&FILE_NAMED_STREAMS)) { ReadNumStreams = false; ReadStreamsSize = false; } string strComputerName; if (ReadOwners) { string strTemp; CurPath2ComputerName(strCurDir, strComputerName, strTemp); } SetLastError(ERROR_SUCCESS); // сформируем заголовок вне цикла string Title = MakeSeparator(X2-X1-1, 9, nullptr); BOOL IsShowTitle=FALSE; BOOL NeedHighlight=Global->Opt->Highlight && PanelMode != PLUGIN_PANEL; if (!Filter) Filter = std::make_unique<FileFilter>(this,FFT_PANEL); //Рефреш текущему времени для фильтра перед началом операции Filter->UpdateCurrentTime(); Global->CtrlObject->HiFiles->UpdateCurrentTime(); bool bCurDirRoot = false; ParsePath(strCurDir, nullptr, &bCurDirRoot); PATH_TYPE Type = ParsePath(strCurDir, nullptr, &bCurDirRoot); bool NetRoot = bCurDirRoot && (Type == PATH_REMOTE || Type == PATH_REMOTEUNC); string strFind(strCurDir); AddEndSlash(strFind); strFind+=L'*'; api::FindFile Find(strFind, true); DWORD FindErrorCode = ERROR_SUCCESS; bool UseFilter=Filter->IsEnabledOnPanel(); bool ReadCustomData=IsColumnDisplayed(CUSTOM_COLUMN0)!=0; DWORD StartTime = GetTickCount(); std::all_of(CONST_RANGE(Find, fdata) -> bool { Global->CatchError(); FindErrorCode = Global->CaughtError(); if ((Global->Opt->ShowHidden || !(fdata.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))) && (!UseFilter || Filter->FileInFilter(fdata, nullptr, &fdata.strFileName))) { if (ListData.size() == ListData.capacity()) ListData.reserve(ListData.size() + 4096); ListData.emplace_back(VALUE_TYPE(ListData)()); auto& NewItem = ListData.back(); NewItem.FileAttr = fdata.dwFileAttributes; NewItem.CreationTime = fdata.ftCreationTime; NewItem.AccessTime = fdata.ftLastAccessTime; NewItem.WriteTime = fdata.ftLastWriteTime; NewItem.ChangeTime = fdata.ftChangeTime; NewItem.FileSize = fdata.nFileSize; NewItem.AllocationSize = fdata.nAllocationSize; NewItem.strName = fdata.strFileName; NewItem.strShortName = fdata.strAlternateFileName; NewItem.Position = ListData.size() - 1; NewItem.NumberOfLinks=1; if (fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { NewItem.ReparseTag=fdata.dwReserved0; //MSDN } if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { TotalFileSize += NewItem.FileSize; if (ReadNumLinks) NewItem.NumberOfLinks = GetNumberOfLinks(fdata.strFileName, true); } else { NewItem.AllocationSize = 0; } NewItem.SortGroup=DEFAULT_SORT_GROUP; if (ReadOwners) { string strOwner; GetFileOwner(strComputerName, NewItem.strName,strOwner); NewItem.strOwner = strOwner; } NewItem.NumberOfStreams=NewItem.FileAttr&FILE_ATTRIBUTE_DIRECTORY?0:1; NewItem.StreamsSize=NewItem.FileSize; if (ReadNumStreams||ReadStreamsSize) { EnumStreams(TestParentFolderName(fdata.strFileName)? strCurDir : fdata.strFileName, NewItem.StreamsSize, NewItem.NumberOfStreams); } if (ReadCustomData) NewItem.strCustomData = Global->CtrlObject->Plugins->GetCustomData(NewItem.strName); if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) TotalFileCount++; DWORD CurTime = GetTickCount(); if (CurTime - StartTime > (DWORD)Global->Opt->RedrawTimeout) { StartTime = CurTime; if (IsVisible()) { if (!IsShowTitle) { if (!DrawMessage) { Text(X1+1,Y1,ColorIndexToColor(COL_PANELBOX),Title); IsShowTitle=TRUE; SetColor(Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE); } } LangString strReadMsg(MReadingFiles); strReadMsg << ListData.size(); if (DrawMessage) { ReadFileNamesMsg(strReadMsg); } else { TruncStr(strReadMsg,static_cast<int>(Title.size())-2); int MsgLength=(int)strReadMsg.size(); GotoXY(X1+1+(static_cast<int>(Title.size())-MsgLength-1)/2,Y1); Global->FS << L" "<<strReadMsg<<L" "; } } Global->CtrlObject->Macro.SuspendMacros(true); bool check = CheckForEsc(); Global->CtrlObject->Macro.SuspendMacros(false); if (check) { // break loop return false; } } } return true; });
/* $ 06.07.2001 + Используем CFileMask вместо GetCommaWord, этим самым добиваемся того, что можно использовать маски исключения - Убрал непонятный мне запрет на использование маски файлов типа "*.*" (был когда-то, вроде, такой баг-репорт) */ bool ProcessLocalFileTypes(const wchar_t *Name, const wchar_t *ShortName, int Mode, bool AlwaysWaitFinish) { RenumKeyRecord(FTS.Associations,FTS.TypeFmt,FTS.Type0); MenuItemEx TypesMenuItem; VMenu TypesMenu(MSG(MSelectAssocTitle),nullptr,0,ScrY-4); TypesMenu.SetHelp(FTS.Help); TypesMenu.SetFlags(VMENU_WRAPMODE); TypesMenu.SetPosition(-1,-1,0,0); int DizWidth=GetDescriptionWidth(Name, ShortName); int ActualCmdCount=0; // отображаемых ассоциаций в меню CFileMask FMask; // для работы с масками файлов string strCommand, strDescription; int CommandCount=0; for (int I=0;; I++) { strCommand.Clear(); string strRegKey, strMask; strRegKey.Format(FTS.TypeFmt,I); if (!GetRegKey(strRegKey,FTS.Mask,strMask,L"")) break; if (FMask.Set(strMask,FMF_SILENT)) { if (FMask.Compare(Name)) { LPCWSTR Type=nullptr; switch (Mode) { case FILETYPE_EXEC: Type=FTS.Execute; break; case FILETYPE_VIEW: Type=FTS.View; break; case FILETYPE_EDIT: Type=FTS.Edit; break; case FILETYPE_ALTEXEC: Type=FTS.AltExec; break; case FILETYPE_ALTVIEW: Type=FTS.AltView; break; case FILETYPE_ALTEDIT: Type=FTS.AltEdit; break; } DWORD State=GetRegKey(strRegKey,FTS.State,0xffffffff); if (State&(1<<Mode)) { string strNewCommand; GetRegKey(strRegKey,Type,strNewCommand,L""); if (!strNewCommand.IsEmpty()) { strCommand = strNewCommand; GetRegKey(strRegKey,FTS.Desc,strDescription,L""); CommandCount++; } } } if (strCommand.IsEmpty()) continue; } TypesMenuItem.Clear(); string strCommandText = strCommand; SubstFileName(strCommandText,Name,ShortName,nullptr,nullptr,nullptr,nullptr,TRUE); // все "подставлено", теперь проверим условия "if exist" if (!ExtractIfExistCommand(strCommandText)) continue; ActualCmdCount++; string strMenuText; if (DizWidth) { string strTitle; if (!strDescription.IsEmpty()) { strTitle = strDescription; SubstFileName(strTitle, Name,ShortName,nullptr,nullptr,nullptr,nullptr,TRUE); } size_t Pos=0; bool Ampersand=strTitle.Pos(Pos,L'&'); if (DizWidth+Ampersand>ScrX/2 && Ampersand && static_cast<int>(Pos)>DizWidth) Ampersand=false; strMenuText.Format(L"%-*.*s %c ",DizWidth+Ampersand,DizWidth+Ampersand,strTitle.CPtr(),BoxSymbols[BS_V1]); } TruncStr(strCommandText,ScrX-DizWidth-14); strMenuText += strCommandText; TypesMenuItem.strName = strMenuText; TypesMenuItem.SetSelect(!I); TypesMenu.SetUserData(strCommand.CPtr(),0,TypesMenu.AddItem(&TypesMenuItem)); } if (!CommandCount) return false; if (!ActualCmdCount) return true; int ExitCode=0; if (ActualCmdCount>1) { TypesMenu.Process(); ExitCode=TypesMenu.Modal::GetExitCode(); if (ExitCode<0) return true; } int Size=TypesMenu.GetUserDataSize(ExitCode); LPWSTR Command=strCommand.GetBuffer(Size/sizeof(wchar_t)); TypesMenu.GetUserData(Command,Size,ExitCode); strCommand.ReleaseBuffer(Size); string strListName, strAnotherListName; string strShortListName, strAnotherShortListName; int PreserveLFN=SubstFileName(strCommand,Name,ShortName,&strListName,&strAnotherListName, &strShortListName, &strAnotherShortListName); bool ListFileUsed=!strListName.IsEmpty()||!strAnotherListName.IsEmpty()||!strShortListName.IsEmpty()||!strAnotherShortListName.IsEmpty(); // Снова все "подставлено", теперь проверим условия "if exist" if (ExtractIfExistCommand(strCommand)) { PreserveLongName PreserveName(ShortName,PreserveLFN); RemoveExternalSpaces(strCommand); if (!strCommand.IsEmpty()) { bool isSilent=(strCommand.At(0)==L'@'); if (isSilent) { strCommand.LShift(1); } ProcessOSAliases(strCommand); if (!isSilent) { CtrlObject->CmdLine->ExecString(strCommand,AlwaysWaitFinish, false, false, ListFileUsed); if (!(Opt.ExcludeCmdHistory&EXCLUDECMDHISTORY_NOTFARASS) && !AlwaysWaitFinish) //AN CtrlObject->CmdHistory->AddToHistory(strCommand); } else { #if 1 SaveScreen SaveScr; CtrlObject->Cp()->LeftPanel->CloseFile(); CtrlObject->Cp()->RightPanel->CloseFile(); Execute(strCommand,AlwaysWaitFinish, 0, 0, 0, ListFileUsed, true); #else // здесь была бага с прорисовкой (и... вывод данных // на команду "@type !@!" пропадал с экрана) // сделаем по аналогии с CommandLine::CmdExecute() { RedrawDesktop RdrwDesktop(TRUE); Execute(strCommand,AlwaysWaitFinish, 0, 0, 0, ListFileUsed); ScrollScreen(1); // обязательно, иначе деструктор RedrawDesktop // проредравив экран забьет последнюю строку вывода. } CtrlObject->Cp()->LeftPanel->UpdateIfChanged(UIC_UPDATE_FORCE); CtrlObject->Cp()->RightPanel->UpdateIfChanged(UIC_UPDATE_FORCE); CtrlObject->Cp()->Redraw(); #endif } if (FrameManager->GetCurrentFrame()->GetType()==MODALTYPE_VIEWER) { TypesMenu.ResetCursor(); } } } if (!strListName.IsEmpty()) apiDeleteFile(strListName); if (!strAnotherListName.IsEmpty()) apiDeleteFile(strAnotherListName); if (!strShortListName.IsEmpty()) apiDeleteFile(strShortListName); if (!strAnotherShortListName.IsEmpty()) apiDeleteFile(strAnotherShortListName); return true; }
void PrintFiles(Panel *SrcPanel) { _ALGO(CleverSysLog clv(L"Alt-F5 (PrintFiles)")); string strPrinterName; DWORD Needed,Returned; int PrinterNumber; DWORD FileAttr; string strSelName; long DirsCount=0; int SelCount=SrcPanel->GetSelCount(); if (!SelCount) { _ALGO(SysLog(L"Error: !SelCount")); return; } // проверка каталогов _ALGO(SysLog(L"Check for FILE_ATTRIBUTE_DIRECTORY")); SrcPanel->GetSelName(nullptr,FileAttr); while (SrcPanel->GetSelName(&strSelName,FileAttr)) { if (TestParentFolderName(strSelName) || (FileAttr & FILE_ATTRIBUTE_DIRECTORY)) DirsCount++; } if (DirsCount==SelCount) return; PRINTER_INFO *pi = nullptr; if (EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS,nullptr,PRINTER_INFO_LEVEL,nullptr,0,&Needed,&Returned) || Needed<=0) return; pi = (PRINTER_INFO *)xf_malloc(Needed); if (!EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS,nullptr,PRINTER_INFO_LEVEL,(LPBYTE)pi,Needed,&Needed,&Returned)) { Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MPrintTitle),MSG(MCannotEnumeratePrinters),MSG(MOk)); xf_free(pi); return; } { _ALGO(CleverSysLog clv2(L"Show Menu")); string strTitle; string strName; if (SelCount==1) { SrcPanel->GetSelName(nullptr,FileAttr); SrcPanel->GetSelName(&strName,FileAttr); TruncStr(strName,50); strSelName=strName; InsertQuote(strSelName); strTitle.Format(MSG(MPrintTo), strSelName.CPtr()); } else { _ALGO(SysLog(L"Correct: SelCount-=DirsCount")); SelCount-=DirsCount; strTitle.Format(MSG(MPrintFilesTo),SelCount); } VMenu PrinterList(strTitle,nullptr,0,ScrY-4); PrinterList.SetFlags(VMENU_WRAPMODE|VMENU_SHOWAMPERSAND); PrinterList.SetPosition(-1,-1,0,0); AddToPrintersMenu(&PrinterList,pi,Returned); PrinterList.Process(); PrinterNumber=PrinterList.Modal::GetExitCode(); if (PrinterNumber<0) { xf_free(pi); _ALGO(SysLog(L"ESC")); return; } int nSize = PrinterList.GetUserDataSize(); wchar_t *PrinterName = strPrinterName.GetBuffer(nSize); PrinterList.GetUserData(PrinterName, nSize); strPrinterName.ReleaseBuffer(); } HANDLE hPrinter; if (!OpenPrinter((wchar_t*)strPrinterName.CPtr(),&hPrinter,nullptr)) { Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MPrintTitle),MSG(MCannotOpenPrinter), strPrinterName,MSG(MOk)); xf_free(pi); _ALGO(SysLog(L"Error: Cannot Open Printer")); return; } { _ALGO(CleverSysLog clv3(L"Print selected Files")); //SaveScreen SaveScr; TPreRedrawFuncGuard preRedrawFuncGuard(PR_PrintMsg); SetCursorType(FALSE,0); PR_PrintMsg(); HANDLE hPlugin=SrcPanel->GetPluginHandle(); int PluginMode=SrcPanel->GetMode()==PLUGIN_PANEL && !CtrlObject->Plugins.UseFarCommand(hPlugin,PLUGIN_FARGETFILE); SrcPanel->GetSelName(nullptr,FileAttr); while (SrcPanel->GetSelName(&strSelName,FileAttr)) { if (TestParentFolderName(strSelName) || (FileAttr & FILE_ATTRIBUTE_DIRECTORY)) continue; int Success=FALSE; LPCWSTR FileName = nullptr; string strTempDir, strTempName; if (PluginMode) { if (FarMkTempEx(strTempDir)) { apiCreateDirectory(strTempDir,nullptr); FileListItem ListItem; if (SrcPanel->GetLastSelectedItem(&ListItem)) { PluginPanelItem PanelItem; FileList::FileListToPluginItem(&ListItem,&PanelItem); if (CtrlObject->Plugins.GetFile(hPlugin,&PanelItem,strTempDir,strTempName,OPM_SILENT)) FileName = strTempName; else apiRemoveDirectory(strTempDir); FileList::FreePluginPanelItem(&PanelItem); } } } else FileName = strSelName; File SrcFile; if(SrcFile.Open(FileName, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, nullptr, OPEN_EXISTING)) { DOC_INFO_1 di1 = {const_cast<LPWSTR>(FileName)}; if (StartDocPrinter(hPrinter,1,(LPBYTE)&di1)) { char Buffer[8192]; DWORD Read,Written; Success=TRUE; while (SrcFile.Read(Buffer, sizeof(Buffer), Read) && Read > 0) if (!WritePrinter(hPrinter,Buffer,Read,&Written)) { Success=FALSE; break; } EndDocPrinter(hPrinter); } SrcFile.Close(); } if (!strTempName.IsEmpty()) { DeleteFileWithFolder(strTempName); } if (Success) SrcPanel->ClearLastGetSelection(); else { if (Message(MSG_WARNING|MSG_ERRORTYPE,2,MSG(MPrintTitle),MSG(MCannotPrint), strSelName,MSG(MSkip),MSG(MCancel))) break; } } ClosePrinter(hPrinter); } SrcPanel->Redraw(); xf_free(pi); }
void PrintFiles(FileList* SrcPanel) { _ALGO(CleverSysLog clv(L"Alt-F5 (PrintFiles)")); string strPrinterName; DWORD Needed = 0, Returned; DWORD FileAttr; string strSelName; size_t DirsCount=0; size_t SelCount=SrcPanel->GetSelCount(); if (!SelCount) { _ALGO(SysLog(L"Error: !SelCount")); return; } // проверка каталогов _ALGO(SysLog(L"Check for FILE_ATTRIBUTE_DIRECTORY")); SrcPanel->GetSelName(nullptr,FileAttr); while (SrcPanel->GetSelName(&strSelName,FileAttr)) { if (TestParentFolderName(strSelName) || (FileAttr & FILE_ATTRIBUTE_DIRECTORY)) DirsCount++; } if (DirsCount==SelCount) return; EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, nullptr, PRINTER_INFO_LEVEL, nullptr, 0, &Needed, &Returned); if (!Needed) return; block_ptr<PRINTER_INFO> pi(Needed); if (!EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS,nullptr,PRINTER_INFO_LEVEL,(LPBYTE)pi.get(),Needed,&Needed,&Returned)) { Global->CatchError(); Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MPrintTitle),MSG(MCannotEnumeratePrinters),MSG(MOk)); return; } { _ALGO(CleverSysLog clv2(L"Show Menu")); LangString strTitle; string strName; if (SelCount==1) { SrcPanel->GetSelName(nullptr,FileAttr); SrcPanel->GetSelName(&strName,FileAttr); strSelName = TruncStr(strName,50); strTitle = MPrintTo; strTitle << InsertQuote(strSelName); } else { _ALGO(SysLog(L"Correct: SelCount-=DirsCount")); SelCount-=DirsCount; strTitle = MPrintFilesTo; strTitle << SelCount; } VMenu2 PrinterList(strTitle,nullptr,0,ScrY-4); PrinterList.SetFlags(VMENU_WRAPMODE|VMENU_SHOWAMPERSAND); PrinterList.SetPosition(-1,-1,0,0); AddToPrintersMenu(&PrinterList,pi.get(),Returned); if (PrinterList.Run()<0) { _ALGO(SysLog(L"ESC")); return; } strPrinterName = NullToEmpty(static_cast<const wchar_t*>(PrinterList.GetUserData(nullptr, 0))); } HANDLE hPrinter; if (!OpenPrinter(UNSAFE_CSTR(strPrinterName), &hPrinter,nullptr)) { Global->CatchError(); Message(MSG_WARNING|MSG_ERRORTYPE,1,MSG(MPrintTitle),MSG(MCannotOpenPrinter), strPrinterName.data(),MSG(MOk)); _ALGO(SysLog(L"Error: Cannot Open Printer")); return; } { _ALGO(CleverSysLog clv3(L"Print selected Files")); SCOPED_ACTION(SaveScreen); auto PR_PrintMsg = [](){ Message(0, 0, MSG(MPrintTitle), MSG(MPreparingForPrinting)); }; SCOPED_ACTION(TPreRedrawFuncGuard)(std::make_unique<PreRedrawItem>(PR_PrintMsg)); SetCursorType(false, 0); PR_PrintMsg(); auto hPlugin=SrcPanel->GetPluginHandle(); int PluginMode=SrcPanel->GetMode()==PLUGIN_PANEL && !Global->CtrlObject->Plugins->UseFarCommand(hPlugin,PLUGIN_FARGETFILE); SrcPanel->GetSelName(nullptr,FileAttr); while (SrcPanel->GetSelName(&strSelName,FileAttr)) { if (TestParentFolderName(strSelName) || (FileAttr & FILE_ATTRIBUTE_DIRECTORY)) continue; int Success=FALSE; string FileName; string strTempDir, strTempName; if (PluginMode) { if (FarMkTempEx(strTempDir)) { api::CreateDirectory(strTempDir,nullptr); auto ListItem = SrcPanel->GetLastSelectedItem(); if (ListItem) { PluginPanelItem PanelItem; FileList::FileListToPluginItem(*ListItem, &PanelItem); if (Global->CtrlObject->Plugins->GetFile(hPlugin,&PanelItem,strTempDir,strTempName,OPM_SILENT)) FileName = strTempName; else api::RemoveDirectory(strTempDir); FreePluginPanelItem(PanelItem); } } } else FileName = strSelName; api::File SrcFile; if(SrcFile.Open(FileName, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, nullptr, OPEN_EXISTING)) { DOC_INFO_1 di1 = {UNSAFE_CSTR(FileName)}; if (StartDocPrinter(hPrinter,1,(LPBYTE)&di1)) { char Buffer[8192]; DWORD Read,Written; Success=TRUE; while (SrcFile.Read(Buffer, sizeof(Buffer), Read) && Read > 0) if (!WritePrinter(hPrinter,Buffer,Read,&Written)) { Global->CatchError(); Success=FALSE; break; } EndDocPrinter(hPrinter); } SrcFile.Close(); } if (!strTempName.empty()) { DeleteFileWithFolder(strTempName); } if (Success) SrcPanel->ClearLastGetSelection(); else { if (Message(MSG_WARNING|MSG_ERRORTYPE,2,MSG(MPrintTitle),MSG(MCannotPrint), strSelName.data(),MSG(MSkip),MSG(MCancel))) break; } } ClosePrinter(hPrinter); } SrcPanel->Redraw(); }
/* Read from system ini file parameter */ char *ReadIni::readIniString( char const *IniFile, char const *Section, char const *Ident, char *sItem, char *defstr ) { FILE *fd; char sBuffer[LINEMAXCHARS], sSect[LINEMAXCHARS], *p , sTmpBuffer[32]; int nAct, nLen; char *pTmp; char sTmp1[LINEMAXCHARS]; if ( sItem == NULL ) return( NULL ); if ( !( fd = fopen( IniFile, "r" ) ) ) return( NULL ); nAct = 0; if ( defstr == NULL ) strcpy( sItem, "" ); else strcpy( sItem, defstr ); strcpy( sSect, "[" ); strcat( sSect, Section ); strcat( sSect, "]" ); memset(sTmpBuffer , 0 , 32); while ( fgets( sBuffer, LINEMAXCHARS, fd ) ) { trim( sBuffer ); pTmp = (char *) sBuffer; /* note or empty line */ if ( ( sBuffer[0] == '#' ) || ( sBuffer[0] == '\n' ) ) continue; /* into back section of the section */ if ( nAct && ( strchr( sBuffer, '[' ) ) && ( strchr( sBuffer, ']' ) ) ) break; /* into the section */ if ( !nAct && strstr( sBuffer, sSect ) ){ nAct = 1; continue; } /* front of the section */ if ( !nAct ) continue; if ( ( p = (char *) strchr( sBuffer, '=' )) && (strcmp( trim(TruncStr( sBuffer , sTmp1 , p - pTmp)) , Ident ) == 0) ) { nLen = 0; if ( p = ( char * )strchr( sBuffer, '#' ) ) nLen = p - sBuffer + 1; nLen = ( nLen? nLen : strlen( sBuffer ) ); sBuffer[nLen-1] = '\0'; p = ( char * )strchr( sBuffer, '=' ) ; nAct = 2 ; break; } } fclose( fd ); if ( nAct == 2 ){ strcpy( sItem, trim( p + 1 ) ); } else if( defstr == NULL ) return( NULL ); return( sItem ); }
void QuickView::DisplayObject() { if (Flags.Check(FSCROBJ_ISREDRAWING)) return; Flags.Set(FSCROBJ_ISREDRAWING); FARString strTitle; if (!QView && !ProcessingPluginCommand) CtrlObject->Cp()->GetAnotherPanel(this)->UpdateViewPanel(); if (QView) QView->SetPosition(X1+1,Y1+1,X2-1,Y2-3); Box(X1,Y1,X2,Y2,COL_PANELBOX,DOUBLE_BOX); SetScreen(X1+1,Y1+1,X2-1,Y2-1,L' ',COL_PANELTEXT); SetColor(Focus ? COL_PANELSELECTEDTITLE:COL_PANELTITLE); GetTitle(strTitle); if (!strTitle.IsEmpty()) { GotoXY(X1+(X2-X1+1-(int)strTitle.GetLength())/2,Y1); Text(strTitle); } DrawSeparator(Y2-2); SetColor(COL_PANELTEXT); GotoXY(X1+1,Y2-1); FS<<fmt::LeftAlign()<<fmt::Width(X2-X1-1)<<fmt::Precision(X2-X1-1)<<PointToName(strCurFileName); if (!strCurFileType.IsEmpty()) { FARString strTypeText=L" "; strTypeText+=strCurFileType; strTypeText+=L" "; TruncStr(strTypeText,X2-X1-1); SetColor(COL_PANELSELECTEDINFO); GotoXY(X1+(X2-X1+1-(int)strTypeText.GetLength())/2,Y2-2); Text(strTypeText); } if (Directory) { FormatString FString; FString<<MSG(MQuickViewFolder)<<L" \""<<strCurFileName<<L"\""; SetColor(COL_PANELTEXT); GotoXY(X1+2,Y1+2); PrintText(FString); /*if ((apiGetFileAttributes(strCurFileName)&FILE_ATTRIBUTE_REPARSE_POINT) == FILE_ATTRIBUTE_REPARSE_POINT) { FARString strJuncName; DWORD ReparseTag=0; if (GetReparsePointInfo(strCurFileName, strJuncName,&ReparseTag)) { int ID_Msg=MQuickViewJunction; if (ReparseTag==IO_REPARSE_TAG_MOUNT_POINT) { if (IsLocalVolumeRootPath(strJuncName)) { ID_Msg=MQuickViewVolMount; } } else if (ReparseTag==IO_REPARSE_TAG_SYMLINK) { ID_Msg=MQuickViewSymlink; } //"\??\D:\Junc\Src\" NormalizeSymlinkName(strJuncName); TruncPathStr(strJuncName,X2-X1-1-StrLength(MSG(ID_Msg))); FString.Clear(); FString<<MSG(ID_Msg)<<L" \""<<strJuncName<<L"\""; SetColor(COL_PANELTEXT); GotoXY(X1+2,Y1+3); PrintText(FString); } }*/ if (Directory==1 || Directory==4) { GotoXY(X1+2,Y1+4); PrintText(MSG(MQuickViewContains)); GotoXY(X1+2,Y1+6); PrintText(MSG(MQuickViewFolders)); SetColor(COL_PANELINFOTEXT); FString.Clear(); FString<<DirCount; PrintText(FString); SetColor(COL_PANELTEXT); GotoXY(X1+2,Y1+7); PrintText(MSG(MQuickViewFiles)); SetColor(COL_PANELINFOTEXT); FString.Clear(); FString<<FileCount; PrintText(FString); SetColor(COL_PANELTEXT); GotoXY(X1+2,Y1+8); PrintText(MSG(MQuickViewBytes)); SetColor(COL_PANELINFOTEXT); FARString strSize; InsertCommas(FileSize,strSize); PrintText(strSize); SetColor(COL_PANELTEXT); GotoXY(X1+2,Y1+9); PrintText(MSG(MQuickViewCompressed)); SetColor(COL_PANELINFOTEXT); InsertCommas(CompressedFileSize,strSize); PrintText(strSize); SetColor(COL_PANELTEXT); GotoXY(X1+2,Y1+10); PrintText(MSG(MQuickViewRatio)); SetColor(COL_PANELINFOTEXT); FString.Clear(); FString<<ToPercent64(CompressedFileSize,FileSize)<<L"%"; PrintText(FString); if (Directory!=4 && RealFileSize>=CompressedFileSize) { SetColor(COL_PANELTEXT); GotoXY(X1+2,Y1+12); PrintText(MSG(MQuickViewCluster)); SetColor(COL_PANELINFOTEXT); FARString strSize; InsertCommas(ClusterSize,strSize); PrintText(strSize); SetColor(COL_PANELTEXT); GotoXY(X1+2,Y1+13); PrintText(MSG(MQuickViewRealSize)); SetColor(COL_PANELINFOTEXT); InsertCommas(RealFileSize,strSize); PrintText(strSize); SetColor(COL_PANELTEXT); GotoXY(X1+2,Y1+14); PrintText(MSG(MQuickViewSlack)); SetColor(COL_PANELINFOTEXT); InsertCommas(RealFileSize-CompressedFileSize,strSize); uint64_t Size1=RealFileSize-CompressedFileSize; uint64_t Size2=RealFileSize; while ((Size2 >> 32) ) { Size1=Size1>>1; Size2=Size2>>1; } FString.Clear(); FString<<strSize<<L" ("<<ToPercent((DWORD)Size1, (DWORD)Size2)<<L"%)"; PrintText(FString); } }