bool OperCFThread::DeleteList( FS* fs, FSPath& _path, FSList& list ) { if ( Info()->Stopped() ) { return false; } FSPath path = _path; int cnt = path.Count(); for ( FSNode* node = list.First(); node; node = node->next ) { if ( node->extType ) { continue; } path.SetItemStr( cnt, node->Name() ); if ( node->IsDir() && !node->st.IsLnk() ) { if ( !DeleteDir( fs, path ) ) { return false; } if ( !RmDir( fs, path ) ) { return false; } continue; } if ( !DeleteFile( fs, path ) ) { return false; } } return true; }
bool DeleteListRecursively( FS* fs, FSPath path, FSList& list ) { const int cnt = path.Count(); int ret_err; for ( FSNode* node = list.First(); node; node = node->next ) { if ( node->extType ) { continue; } path.SetItemStr( cnt, node->Name() ); if ( node->IsDir() && !node->st.IsLnk() ) { if ( !DeleteDirRecursively( fs, path ) ) { return false; } } else if ( fs->Delete( path, &ret_err, nullptr ) != 0 ) { return false; } } return true; }
void OperDirCalcThread::Calc() { MutexLock lock( Node().GetMutex() ); if ( !Node().Data() ) { return; } OperDirCalcData* CalcData = ( OperDirCalcData* )Node().Data(); clPtr<FS> fs = CalcData->dirFs; FSPath path = CalcData->_path; clPtr<FSList> list = CalcData->dirList; lock.Unlock(); //!!! //dbg_printf("OperDirCalcThread::Calc list data:"); //path.dbg_printf("FSPath:"); //for (FSNode* node = list->First(); node; node = node->next) // dbg_printf("%s\n", node->name.GetUtf8()); if (list->Count() == 0) { // then calculate current dir size CalcDir(fs.Ptr(), path); } else { // list is not empty: calculate size of objects in the list int cnt = path.Count(); for (FSNode* node = list->First(); node; node = node->next) { path.SetItemStr(cnt, node->Name()); //-V595 bool IsDir = node->IsDir() && !node->st.IsLnk(); if ( IsDir ) { int64_t Size = CalcDir( fs.Ptr(), path); if ( Size >= 0 && node && node->originNode ) { node->originNode->st.size = Size; } CalcData->folderCount++; } else { CalcData->fileCount++; CalcData->sumSize += node->st.size; } } } }
void PanelList::InvertSelection() { int n = listCount; selectedCn.Clear(); for ( int i = 0; i < n; i++ ) { FSNode* p = list.data()[i]; if ( p->IsSelected() ) { p->ClearSelected(); } else { if ( !wcmConfig.panelSelectFolders && p->IsDir() ) { continue; } p->SetSelected(); selectedCn.AddOne( p->st.size ); } } };
void PanelList::MakeList() { listCount = 0; list.clear(); filesCnNoDirs.Clear(); filesCn.Clear(); selectedCn.Clear(); hiddenCn.Clear(); if ( data.ptr() && data->Count() > 0 ) { int n = data->Count(); list.resize( n ); int i = 0; for ( FSNode* p = data->First(); p && i < n; p = p->next ) if ( showHidden || !p->IsHidden() ) { list[ i++ ] = p; filesCn.AddOne( p->st.size ); if ( p->IsSelected() ) { selectedCn.AddOne( p->st.size ); } if ( !p->IsDir() ) { filesCnNoDirs.AddOne( p->st.size ); } } else { p->ClearSelected(); hiddenCn.AddOne( p->st.size ); } listCount = i; } }