// This function will take a resolved URI and create a version of it that is relative to // another existing URI. The new URI is stored in the "originalURI" int daeURI::makeRelativeTo(daeURI* relativeToURI) { // !!!GAC for some reason, relativeToURI is in pending and not success state, why?? // Can't do this function unless both URIs have already been successfully resolved if(getState() != uri_success /*|| relativeToURI->getState() != uri_success*/ ) return(DAE_ERR_INVALID_CALL); // !!!GAC Need to assign a real error code to this // Can only do this function if both URIs have the same scheme and authority if((strcmp(getProtocol(), relativeToURI->getProtocol()) != 0) || (strcmp(getAuthority(), relativeToURI->getAuthority()) != 0)) return(DAE_ERR_INVALID_CALL); // !!!GAC Need to assign a real error code to this // advance till we find a segment that doesn't match const char *this_filepath = getFilepath(); const char *relativeTo_filepath = relativeToURI->getFilepath(); const char *this_slash = this_filepath; const char *relativeTo_slash = relativeTo_filepath; while(*this_filepath == *relativeTo_filepath) { if(*this_filepath == '/') { this_slash = this_filepath; relativeTo_slash = relativeTo_filepath; } this_filepath++; relativeTo_filepath++; } // Decide how many ../ segments are needed (Filepath should always end in a /) int segment_count = 0; relativeTo_slash++; while(*relativeTo_slash != 0) { if(*relativeTo_slash == '/') segment_count ++; relativeTo_slash++; } this_slash++; // Delete old URI string safeDelete(originalURIString); // Allocate memory for a new "originalURI" and free the old one char *newRelativeURI = (char*) daeMemorySystem::malloc("uri",strlen(relativeTo_slash)+ strlen(file)+(segment_count*3)+strlen(getID())+2); char *temp = newRelativeURI; for(int i = 0; i < segment_count; i++) { strcpy(temp,"../"); temp += 3; } strcpy(temp,this_slash); strcat(temp,file); if(id!=empty && strlen(getID()) != 0) { strcat(temp,"#"); strcat(temp,getID()); } originalURIString = newRelativeURI; return(DAE_OK); }
Mesh::Mesh(string directory, string filename) : File(directory, filename) { #warning make sure all meshes have filenames even if they are not loaded from a file // This constructor loads geometry data (vertices and faces) from a .obj file. MeshLoader mesh_loader = MeshLoader(getFilepath()); std::vector<GLfloat> vertices = mesh_loader.getVertexArray(); std::vector<GLuint> elements = mesh_loader.getFaceArray(); loadMeshData(vertices, elements); }
void Repository::Git::GitFile::printContent() { // vypise informacie o subore qDebug() << "filename: " << getFilename(); qDebug() << "filepath: " << getFilepath(); qDebug() << "type: " << getTypeAsString(); // pre kazdy diff blok vypis informacie o danom bloku foreach ( GitFileDiffBlock* block, getGitFileDiffBlocks() ) { block->printInfo(); } }
QList<QString> ParserM3u::parse(QString sFilename) { QFile file(sFilename); QString basepath = sFilename.section('/', 0, -2); clearLocations(); //qDebug() << "ParserM3u: Starting to parse."; if (file.open(QIODevice::ReadOnly) && !isBinary(sFilename)) { /* Unfortunately, QT 4.7 does not handle <CR> (=\r or asci value 13) line breaks. * This is important on OS X where iTunes, e.g., exports M3U playlists using <CR> * rather that <LF> * * Using QFile::readAll() we obtain the complete content of the playlist as a ByteArray. * We replace any '\r' with '\n' if applicaple * This ensures that playlists from iTunes on OS X can be parsed */ QByteArray ba = file.readAll(); //detect encoding bool isCRLF_encoded = ba.contains("\r\n"); bool isCR_encoded = ba.contains("\r"); if(isCR_encoded && !isCRLF_encoded) ba.replace('\r','\n'); QTextStream textstream(ba.constData()); if (isUtf8(ba.constData())) { textstream.setCodec("UTF-8"); } else { textstream.setCodec("windows-1252"); } while(!textstream.atEnd()) { QString sLine = getFilepath(&textstream, basepath); if(sLine.isEmpty()) break; //qDebug() << "ParserM3u: parsed: " << (sLine); m_sLocations.append(sLine); } file.close(); if(m_sLocations.count() != 0) return m_sLocations; else return QList<QString>(); // NULL pointer returned when no locations were found } file.close(); return QList<QString>(); //if we get here something went wrong }
void ImageArtwork::attachVector(const QString &vectorFilepath) { LOG_INFO << "Attaching vector file:" << vectorFilepath << "to file" << getFilepath(); setHasVectorAttachedFlag(true); m_AttachedVector = vectorFilepath; }