void ropen(void) { Xfile *f; f = xfile(req->fid, Asis); if(f->flags&Omodes) error("open on open file"); if(req->mode&ORCLOSE) error("no removes"); (*f->xf->s->open)(f, req->mode); f->flags = openflags(req->mode); rep->qid = f->qid; rep->iounit = 0; }
static QByteArray fileData_( const QString& path, bool astext = false ) { QByteArray data; QFile file( path ); if ( file.exists() ) { QFile::OpenMode openflags( QIODevice::ReadOnly ); if ( astext ) openflags |= QIODevice::Text; bool ret = file.open( openflags ); if ( ret ) { data = file.readAll(); } file.close(); } return data; }
bool QgsAuthPkiPathsEdit::validateConfig() { // required components QString certpath( lePkiPathsCert->text() ); QString keypath( lePkiPathsKey->text() ); bool certfound = QFile::exists( certpath ); bool keyfound = QFile::exists( keypath ); QgsAuthGuiUtils::fileFound( certpath.isEmpty() || certfound, lePkiPathsCert ); QgsAuthGuiUtils::fileFound( keypath.isEmpty() || keyfound, lePkiPathsKey ); if ( !certfound || !keyfound ) { writePkiMessage( lePkiPathsMsg, tr( "Missing components" ), Invalid ); return validityChange( false ); } // check for issue date validity, then notify status QSslCertificate cert; QFile file( certpath ); QFileInfo fileinfo( file ); QString ext( fileinfo.fileName().replace( fileinfo.completeBaseName(), "" ).toLower() ); if ( ext.isEmpty() ) { writePkiMessage( lePkiPathsMsg, tr( "Certificate file has no extension" ), Invalid ); return validityChange( false ); } QFile::OpenMode openflags( QIODevice::ReadOnly ); QSsl::EncodingFormat encformat( QSsl::Der ); if ( ext == ".pem" ) { openflags |= QIODevice::Text; encformat = QSsl::Pem; } if ( file.open( openflags ) ) { cert = QSslCertificate( file.readAll(), encformat ); file.close(); } else { writePkiMessage( lePkiPathsMsg, tr( "Failed to read certificate file" ), Invalid ); return validityChange( false ); } if ( cert.isNull() ) { writePkiMessage( lePkiPathsMsg, tr( "Failed to load certificate from file" ), Invalid ); return validityChange( false ); } bool certvalid = cert.isValid(); QDateTime startdate( cert.effectiveDate() ); QDateTime enddate( cert.expiryDate() ); writePkiMessage( lePkiPathsMsg, tr( "%1 thru %2" ).arg( startdate.toString(), enddate.toString() ), ( certvalid ? Valid : Invalid ) ); return validityChange( certvalid ); }