QString KoStore::expandEncodedPath( QString intern ) const { if ( m_namingVersion == NAMING_VERSION_RAW ) return intern; QString result; int pos; if ( ( pos = intern.findRev( '/', -1 ) ) != -1 ) { result = expandEncodedDirectory( intern.left( pos ) ) + '/'; intern = intern.mid( pos + 1 ); } // Now process the filename. If the first character is numeric, we have // a main document. if ( QChar(intern.at(0)).isDigit() ) { // If this is the first part name, check if we have a store with // old-style names. if ( ( m_namingVersion == NAMING_VERSION_2_2 ) && ( m_mode == Read ) && ( fileExists( result + "part" + intern + ".xml" ) ) ) m_namingVersion = NAMING_VERSION_2_1; if ( m_namingVersion == NAMING_VERSION_2_1 ) result = result + "part" + intern + ".xml"; else result = result + "part" + intern + "/" + MAINNAME; } else result += intern; return result; }
QString KoStorePrivate::expandEncodedPath(const QString& _intern) const { QString intern = _intern; if (namingVersion == KoStorePrivate::NamingVersionRaw) return intern; QString result; int pos; if ((pos = intern.lastIndexOf('/', -1)) != -1) { result = expandEncodedDirectory(intern.left(pos)) + '/'; intern = intern.mid(pos + 1); } // Now process the filename. If the first character is numeric, we have // a main document. if (QChar(intern.at(0)).isDigit()) { // If this is the first part name, check if we have a store with // old-style names. if (namingVersion == KoStorePrivate::NamingVersion22 && mode == KoStore::Read && q->fileExists(result + "part" + intern + ".xml")) namingVersion = KoStorePrivate::NamingVersion21; if (namingVersion == KoStorePrivate::NamingVersion21) result = result + "part" + intern + ".xml"; else result = result + "part" + intern + '/' + MAINNAME; } else { result += intern; } return result; }
bool KoStorePrivate::enterDirectoryInternal(const QString &directory) { if (q->enterRelativeDirectory(expandEncodedDirectory(directory))) { currentPath.append(directory); return true; } return false; }
bool KoStore::leaveDirectory() { if ( m_currentPath.isEmpty() ) return false; m_currentPath.pop_back(); return enterAbsoluteDirectory( expandEncodedDirectory( currentPath() ) ); }
// See the specification for details of what this function does. QString KoStore::toExternalNaming( const QString & _internalNaming ) const { if ( _internalNaming == ROOTPART ) return expandEncodedDirectory( currentPath() ) + MAINNAME; QString intern; if ( _internalNaming.startsWith( "tar:/" ) ) // absolute reference intern = _internalNaming.mid( 5 ); // remove protocol else intern = currentPath() + _internalNaming; return expandEncodedPath( intern ); }
QString KoStore::currentDirectory() const { return expandEncodedDirectory( currentPath() ); }