void fileCallback(LPCWSTR a){ LPCWSTR name = wcsrchr(a, '/') + 1;; UINT lines = countFileLines(a); gLines += lines; UINT depth = pathDepth(a); for (UINT i = depth; i > gBegPathDepth; --i) putchar(' '); wprintf(L"%s [%d]\n", name, lines); }
DataHandler* AnyDimHandler::copy( unsigned short newParentDepth, unsigned short copyRootDepth, bool toGlobal, unsigned int n ) const { if ( toGlobal ) { if ( !isGlobal() ) { cout << "Warning: AnyDimHandler::copy: Cannot copy from nonGlob al to global\n"; return 0; } } // Don't allow copying that would remove an array. for ( unsigned int i = 0; i < dims_.size(); ++i ) if ( copyRootDepth > dims_[i].depth ) return 0; if ( n > 1 ) { DimInfo temp = {n, newParentDepth + 1, 0 }; vector< DimInfo > newDims; newDims.push_back( temp ); for ( unsigned int i = 0; i < dims_.size(); ++i ) { newDims.push_back( dims_[i] ); newDims.back().depth += 1 + newParentDepth - copyRootDepth; } AnyDimHandler* ret = new AnyDimHandler( dinfo(), newDims, 1 + pathDepth() + newParentDepth - copyRootDepth, toGlobal ); if ( data_ ) { ret->assign( data_, end_ - start_ ); } return ret; } else { AnyDimHandler* ret = new AnyDimHandler( this ); if ( !ret->changeDepth( pathDepth() + 1 + newParentDepth - copyRootDepth ) ) { delete ret; return 0; } return ret; } return 0; }
DataHandler* TwoDimHandler::copy( unsigned short newParentDepth, unsigned short copyRootDepth, bool toGlobal, unsigned int n ) const { if ( toGlobal ) { if ( !isGlobal() ) { cout << "Warning: TwoDimHandler::copy: Cannot copy from nonGlob al to global\n"; return 0; } } if ( copyRootDepth > dims_[0].depth || copyRootDepth >= dims_[1].depth) return 0; if ( n > 1 ) { DimInfo temp = {n, newParentDepth + 1, 0 }; vector< DimInfo > newDims; newDims.push_back( temp ); newDims.push_back( dims_[0] ); newDims.back().depth += 1 + newParentDepth - copyRootDepth; newDims.push_back( dims_[1] ); newDims.back().depth += 1 + newParentDepth - copyRootDepth; AnyDimHandler* ret = new AnyDimHandler( dinfo(), newDims, 1 + pathDepth() + newParentDepth - copyRootDepth, toGlobal ); if ( data_ ) { ret->assign( data_, end_ - start_ ); } return ret; } else { TwoDimHandler* ret = new TwoDimHandler( this ); if ( !ret->changeDepth( pathDepth() + 1 + newParentDepth - copyRootDepth ) ) { delete ret; return 0; } return ret; } return 0; }
int main(){ gheap = GetProcessHeap(); wprintf(L"FILE NAME [LINES]\n-----------------\n"); gBegPathDepth = pathDepth(L"C:/*"); findAllFilesFromDirection(L"C:/*", dirCallback, fileCallback); wprintf(L"-----------------\nTOTAL: %d\n", gLines); /*UINT64 lines = 0; WIN32_FIND_DATA fnddata = { 0 }; WCHAR pathBuf[MAX_PATH] = L"C:/testloc/*"; SIZE_T pathLen = lstrlen(pathBuf); HANDLE hfnd = FindFirstFile(pathBuf, &fnddata); if (hfnd != INVALID_HANDLE_VALUE){ wprintf(L"FILE NAME\t\t\tLINES\n------------------------------------------\n"); do{ if (!(fnddata.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_HIDDEN))){ memcpy(&pathBuf[pathLen - 1], fnddata.cFileName, (lstrlen(fnddata.cFileName) + 1) * 2); UINT64 a = countFileLines(pathBuf); lines += a; wprintf(L"%-32s%d\n", fnddata.cFileName, a); } } while (FindNextFile(hfnd, &fnddata)); wprintf(L"------------------------------------------\nTOTAL:\t\t\t\t%d\n\n", lines); }*/ }
void dirCallback(LPCWSTR a){ LPCWSTR name = wcsrchr(a, '/') + 1;; UINT depth = pathDepth(a); for (UINT i = depth; i > gBegPathDepth; --i) putchar(' '); wprintf(L"[%s]\n", name); }