void FolderSource::sendFolder(File folder, HTTPDecoder& dec) { // get all files in this folder std::vector<File> files; folder.listFiles(files); // struct for filesize-status struct stat fileStats; // process each file for (const auto file : files) { // if this file is another folder -> recursion if (file.isFolder()) { // send this subfolder sendFolder(file, dec); } else { // check file-size to skip 0-byte files stat(file.getAbsolutePath().c_str(), &fileStats); if (fileStats.st_size == 0) {continue;} // send one file sendFile(file, dec); // check if canceled? if (!running) {break;} } } }
void FolderSource::sendFiles() { // dummy http decoder HTTPDecoder dummyDec; // start with the root folder and walk subfolders recursively sendFolder(folder, dummyDec); }
void wavrChatWindow::dropEvent(QDropEvent* pEvent) { QList<QUrl> urls = pEvent->mimeData()->urls(); if(urls.isEmpty()) return; foreach(QUrl url, urls) { QString path = url.toLocalFile(); if(path.isEmpty()) continue; QFileInfo fileInfo(path); if(!fileInfo.exists()) continue; if(fileInfo.isFile()) sendFile(&path); else if(fileInfo.isDir()) sendFolder(&path); }