void sharefile::getItem(QTableWidgetItem* item) { QString fileName; qint64 fileSize; //单位KB QString fileType; QString time; QList<QTableWidgetItem*> temp = ui->tableWidget->selectedItems(); vector<FileInformation>::iterator it; for(it = filelist->begin(); it != filelist->end(); ++it) { if((*it).fileName == temp[1]->text()) { checkedFile = (*it); return; } } checkedFile = FileInformation(); }
FileInformation FileDescriptor::getInfo() const { #ifndef _WIN32 struct stat st; if (fstat(fd_, &st)) { int err = errno; throw std::system_error(err, std::generic_category(), "fstat"); } return FileInformation(st); #else // _WIN32 FILE_BASIC_INFO binfo; FILE_STANDARD_INFO sinfo; if (!GetFileInformationByHandleEx( (HANDLE)handle(), FileBasicInfo, &binfo, sizeof(binfo))) { throw std::system_error( GetLastError(), std::system_category(), "GetFileInformationByHandleEx FileBasicInfo"); } FileInformation info(binfo.FileAttributes); FILETIME_LARGE_INTEGER_to_timespec(binfo.CreationTime, &info.ctime); FILETIME_LARGE_INTEGER_to_timespec(binfo.LastAccessTime, &info.atime); FILETIME_LARGE_INTEGER_to_timespec(binfo.LastWriteTime, &info.mtime); if (!GetFileInformationByHandleEx( (HANDLE)handle(), FileStandardInfo, &sinfo, sizeof(sinfo))) { throw std::system_error( GetLastError(), std::system_category(), "GetFileInformationByHandleEx FileStandardInfo"); } info.size = sinfo.EndOfFile.QuadPart; info.nlink = sinfo.NumberOfLinks; return info; #endif }
FileInformation getFileInformation(const char *path, CaseSensitivity caseSensitive) { auto options = OpenFileHandleOptions::queryFileInfo(); options.caseSensitive = caseSensitive; #if defined(_WIN32) || defined(O_PATH) // These operating systems allow opening symlink nodes and querying them // for stat information auto handle = openFileHandle(path, options); auto info = handle.getInfo(); return info; #else // Since the leaf of the path may be a symlink, and this system doesn't // allow opening symlinks for stat purposes, we have to resort to performing // a relative fstatat() from the parent dir. w_string_piece pathPiece(path); auto parent = pathPiece.dirName().asWString(); auto handle = openFileHandle(parent.c_str(), options); struct stat st; if (fstatat( handle.fd(), pathPiece.baseName().data(), &st, AT_SYMLINK_NOFOLLOW)) { throw std::system_error(errno, std::generic_category(), "fstatat"); } if (caseSensitive == CaseSensitivity::Unknown) { caseSensitive = getCaseSensitivityForPath(path); } if (caseSensitive == CaseSensitivity::CaseInSensitive) { // We need to perform one extra check for case-insensitive // paths to make sure that we didn't accidentally open // the wrong case name. checkCanonicalBaseName(path); } return FileInformation(st); #endif }
QList<FTPTransfer::FileInformation> FTPTransfer::files() const { QList<FileInformation> result; result.append(FileInformation(QFileInfo(URL.path()).fileName(), 0, -1)); return result; }