• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

  • tdeio
  • tdeio
karchive.cpp
1/* This file is part of the KDE libraries
2 Copyright (C) 2000 David Faure <faure@kde.org>
3 Copyright (C) 2003 Leo Savernik <l.savernik@aon.at>
4
5 Moved from ktar.cpp by Roberto Teixeira <maragato@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <time.h>
25#include <unistd.h>
26#include <errno.h>
27#include <grp.h>
28#include <pwd.h>
29#include <assert.h>
30#include <sys/types.h>
31#include <sys/stat.h>
32
33#include <tqptrlist.h>
34#include <tqptrstack.h>
35#include <tqvaluestack.h>
36#include <tqmap.h>
37#include <tqcstring.h>
38#include <tqdir.h>
39#include <tqfile.h>
40
41#include <kdebug.h>
42#include <kfilterdev.h>
43#include <kfilterbase.h>
44#include <kde_file.h>
45
46#include "karchive.h"
47#include "klimitediodevice.h"
48
49template class TQDict<KArchiveEntry>;
50
51
52class KArchive::KArchivePrivate
53{
54public:
55 KArchiveDirectory* rootDir;
56 bool closeSucceeded;
57};
58
59class PosSortedPtrList : public TQPtrList<KArchiveFile> {
60protected:
61 int compareItems( TQPtrCollection::Item i1,
62 TQPtrCollection::Item i2 )
63 {
64 int pos1 = static_cast<KArchiveFile*>( i1 )->position();
65 int pos2 = static_cast<KArchiveFile*>( i2 )->position();
66 return ( pos1 - pos2 );
67 }
68};
69
70
74
75KArchive::KArchive( TQIODevice * dev )
76{
77 d = new KArchivePrivate;
78 d->rootDir = 0;
79 m_dev = dev;
80 m_open = false;
81}
82
83KArchive::~KArchive()
84{
85 if ( m_open )
86 close();
87 delete d->rootDir;
88 delete d;
89}
90
91bool KArchive::open( int mode )
92{
93 if ( m_dev && !m_dev->open( mode ) )
94 return false;
95
96 if ( m_open )
97 close();
98
99 m_mode = mode;
100 m_open = true;
101
102 Q_ASSERT( d->rootDir == 0L );
103 d->rootDir = 0L;
104
105 return openArchive( mode );
106}
107
108void KArchive::close()
109{
110 if ( !m_open )
111 return;
112 // moved by holger to allow kzip to write the zip central dir
113 // to the file in closeArchive()
114 d->closeSucceeded = closeArchive();
115
116 if ( m_dev )
117 m_dev->close();
118
119 delete d->rootDir;
120 d->rootDir = 0;
121 m_open = false;
122}
123
124bool KArchive::closeSucceeded() const
125{
126 return d->closeSucceeded;
127}
128
129const KArchiveDirectory* KArchive::directory() const
130{
131 // rootDir isn't const so that parsing-on-demand is possible
132 return const_cast<KArchive *>(this)->rootDir();
133}
134
135
136bool KArchive::addLocalFile( const TQString& fileName, const TQString& destName )
137{
138 TQFileInfo fileInfo( fileName );
139 if ( !fileInfo.isFile() && !fileInfo.isSymLink() )
140 {
141 kdWarning() << "KArchive::addLocalFile " << fileName << " doesn't exist or is not a regular file." << endl;
142 return false;
143 }
144
145 KDE_struct_stat fi;
146 if (KDE_lstat(TQFile::encodeName(fileName),&fi) == -1) {
147 kdWarning() << "KArchive::addLocalFile stating " << fileName
148 << " failed: " << strerror(errno) << endl;
149 return false;
150 }
151
152 if (fileInfo.isSymLink()) {
153 return writeSymLink(destName, fileInfo.readLink(), fileInfo.owner(),
154 fileInfo.group(), fi.st_mode, fi.st_atime, fi.st_mtime,
155 fi.st_ctime);
156 }/*end if*/
157
158 uint size = fileInfo.size();
159
160 // the file must be opened before prepareWriting is called, otherwise
161 // if the opening fails, no content will follow the already written
162 // header and the tar file is effectively f*cked up
163 TQFile file( fileName );
164 if ( !file.open( IO_ReadOnly ) )
165 {
166 kdWarning() << "KArchive::addLocalFile couldn't open file " << fileName << endl;
167 return false;
168 }
169
170 if ( !prepareWriting( destName, fileInfo.owner(), fileInfo.group(), size,
171 fi.st_mode, fi.st_atime, fi.st_mtime, fi.st_ctime ) )
172 {
173 kdWarning() << "KArchive::addLocalFile prepareWriting " << destName << " failed" << endl;
174 return false;
175 }
176
177 // Read and write data in chunks to minimize memory usage
178 TQByteArray array(8*1024);
179 int n;
180 uint total = 0;
181 while ( ( n = file.readBlock( array.data(), array.size() ) ) > 0 )
182 {
183 if ( !writeData( array.data(), n ) )
184 {
185 kdWarning() << "KArchive::addLocalFile writeData failed" << endl;
186 return false;
187 }
188 total += n;
189 }
190 Q_ASSERT( total == size );
191
192 if ( !doneWriting( size ) )
193 {
194 kdWarning() << "KArchive::addLocalFile doneWriting failed" << endl;
195 return false;
196 }
197 return true;
198}
199
200bool KArchive::addLocalDirectory( const TQString& path, const TQString& destName )
201{
202 TQString dot = ".";
203 TQString dotdot = "..";
204 TQDir dir( path );
205 if ( !dir.exists() )
206 return false;
207 dir.setFilter(dir.filter() | TQDir::Hidden);
208 TQStringList files = dir.entryList();
209 for ( TQStringList::Iterator it = files.begin(); it != files.end(); ++it )
210 {
211 if ( *it != dot && *it != dotdot )
212 {
213 TQString fileName = path + "/" + *it;
214// kdDebug() << "storing " << fileName << endl;
215 TQString dest = destName.isEmpty() ? *it : (destName + "/" + *it);
216 TQFileInfo fileInfo( fileName );
217
218 if ( fileInfo.isFile() || fileInfo.isSymLink() )
219 addLocalFile( fileName, dest );
220 else if ( fileInfo.isDir() )
221 addLocalDirectory( fileName, dest );
222 // We omit sockets
223 }
224 }
225 return true;
226}
227
228bool KArchive::writeFile( const TQString& name, const TQString& user, const TQString& group, uint size, const char* data )
229{
230 mode_t perm = 0100644;
231 time_t the_time = time(0);
232 return writeFile(name,user,group,size,perm,the_time,the_time,the_time,data);
233}
234
235bool KArchive::prepareWriting( const TQString& name, const TQString& user,
236 const TQString& group, uint size, mode_t perm,
237 time_t atime, time_t mtime, time_t ctime ) {
238 PrepareWritingParams params;
239 params.name = &name;
240 params.user = &user;
241 params.group = &group;
242 params.size = size;
243 params.perm = perm;
244 params.atime = atime;
245 params.mtime = mtime;
246 params.ctime = ctime;
247 virtual_hook(VIRTUAL_PREPARE_WRITING,&params);
248 return params.retval;
249}
250
251bool KArchive::prepareWriting_impl(const TQString &name, const TQString &user,
252 const TQString &group, uint size, mode_t /*perm*/,
253 time_t /*atime*/, time_t /*mtime*/, time_t /*ctime*/ ) {
254 kdWarning(7040) << "New prepareWriting API not implemented in this class." << endl
255 << "Falling back to old API (metadata information will be lost)" << endl;
256 return prepareWriting(name,user,group,size);
257}
258
259bool KArchive::writeFile( const TQString& name, const TQString& user,
260 const TQString& group, uint size, mode_t perm,
261 time_t atime, time_t mtime, time_t ctime,
262 const char* data ) {
263 WriteFileParams params;
264 params.name = &name;
265 params.user = &user;
266 params.group = &group;
267 params.size = size;
268 params.perm = perm;
269 params.atime = atime;
270 params.mtime = mtime;
271 params.ctime = ctime;
272 params.data = data;
273 virtual_hook(VIRTUAL_WRITE_FILE,&params);
274 return params.retval;
275}
276
277bool KArchive::writeFile_impl( const TQString& name, const TQString& user,
278 const TQString& group, uint size, mode_t perm,
279 time_t atime, time_t mtime, time_t ctime,
280 const char* data ) {
281
282 if ( !prepareWriting( name, user, group, size, perm, atime, mtime, ctime ) )
283 {
284 kdWarning() << "KArchive::writeFile prepareWriting failed" << endl;
285 return false;
286 }
287
288 // Write data
289 // Note: if data is 0L, don't call writeBlock, it would terminate the KFilterDev
290 if ( data && size && !writeData( data, size ) )
291 {
292 kdWarning() << "KArchive::writeFile writeData failed" << endl;
293 return false;
294 }
295
296 if ( !doneWriting( size ) )
297 {
298 kdWarning() << "KArchive::writeFile doneWriting failed" << endl;
299 return false;
300 }
301 return true;
302}
303
304bool KArchive::writeDir(const TQString& name, const TQString& user,
305 const TQString& group, mode_t perm,
306 time_t atime, time_t mtime, time_t ctime) {
307 WriteDirParams params;
308 params.name = &name;
309 params.user = &user;
310 params.group = &group;
311 params.perm = perm;
312 params.atime = atime;
313 params.mtime = mtime;
314 params.ctime = ctime;
315 virtual_hook(VIRTUAL_WRITE_DIR,&params);
316 return params.retval;
317}
318
319bool KArchive::writeDir_impl(const TQString &name, const TQString &user,
320 const TQString &group, mode_t /*perm*/,
321 time_t /*atime*/, time_t /*mtime*/, time_t /*ctime*/ ) {
322 kdWarning(7040) << "New writeDir API not implemented in this class." << endl
323 << "Falling back to old API (metadata information will be lost)" << endl;
324 return writeDir(name,user,group);
325}
326
327bool KArchive::writeSymLink(const TQString &name, const TQString &target,
328 const TQString &user, const TQString &group,
329 mode_t perm, time_t atime, time_t mtime, time_t ctime) {
330 WriteSymlinkParams params;
331 params.name = &name;
332 params.target = &target;
333 params.user = &user;
334 params.group = &group;
335 params.perm = perm;
336 params.atime = atime;
337 params.mtime = mtime;
338 params.ctime = ctime;
339 virtual_hook(VIRTUAL_WRITE_SYMLINK,&params);
340 return params.retval;
341}
342
343bool KArchive::writeSymLink_impl(const TQString &/*name*/,const TQString &/*target*/,
344 const TQString &/*user*/, const TQString &/*group*/,
345 mode_t /*perm*/, time_t /*atime*/, time_t /*mtime*/,
346 time_t /*ctime*/) {
347 kdWarning(7040) << "writeSymLink not implemented in this class." << endl
348 << "No fallback available." << endl;
349 // FIXME: better return true here for compatibility with KDE < 3.2
350 return false;
351}
352
353bool KArchive::writeData( const char* data, uint size )
354{
355 WriteDataParams params;
356 params.data = data;
357 params.size = size;
358 virtual_hook( VIRTUAL_WRITE_DATA, &params );
359 return params.retval;
360}
361
362bool KArchive::writeData_impl( const char* data, uint size )
363{
364 Q_ASSERT( device() );
365 return device()->writeBlock( data, size ) == (TQ_LONG)size;
366}
367
368KArchiveDirectory * KArchive::rootDir()
369{
370 if ( !d->rootDir )
371 {
372 //kdDebug() << "Making root dir " << endl;
373 struct passwd* pw = getpwuid( getuid() );
374 struct group* grp = getgrgid( getgid() );
375 TQString username = pw ? TQFile::decodeName(pw->pw_name) : TQString::number( getuid() );
376 TQString groupname = grp ? TQFile::decodeName(grp->gr_name) : TQString::number( getgid() );
377
378 d->rootDir = new KArchiveDirectory( this, TQString::fromLatin1("/"), (int)(0777 + S_IFDIR), 0, username, groupname, TQString::null );
379 }
380 return d->rootDir;
381}
382
383KArchiveDirectory * KArchive::findOrCreate( const TQString & path )
384{
385 //kdDebug() << "KArchive::findOrCreate " << path << endl;
386 if ( path.isEmpty() || path == "/" || path == "." ) // root dir => found
387 {
388 //kdDebug() << "KArchive::findOrCreate returning rootdir" << endl;
389 return rootDir();
390 }
391 // Important note : for tar files containing absolute paths
392 // (i.e. beginning with "/"), this means the leading "/" will
393 // be removed (no KDirectory for it), which is exactly the way
394 // the "tar" program works (though it displays a warning about it)
395 // See also KArchiveDirectory::entry().
396
397 // Already created ? => found
398 KArchiveEntry* ent = rootDir()->entry( path );
399 if ( ent )
400 {
401 if ( ent->isDirectory() )
402 //kdDebug() << "KArchive::findOrCreate found it" << endl;
403 return (KArchiveDirectory *) ent;
404 else
405 kdWarning() << "Found " << path << " but it's not a directory" << endl;
406 }
407
408 // Otherwise go up and try again
409 int pos = path.findRev( '/' );
410 KArchiveDirectory * parent;
411 TQString dirname;
412 if ( pos == -1 ) // no more slash => create in root dir
413 {
414 parent = rootDir();
415 dirname = path;
416 }
417 else
418 {
419 TQString left = path.left( pos );
420 dirname = path.mid( pos + 1 );
421 parent = findOrCreate( left ); // recursive call... until we find an existing dir.
422 }
423
424 //kdDebug() << "KTar : found parent " << parent->name() << " adding " << dirname << " to ensure " << path << endl;
425 // Found -> add the missing piece
426 KArchiveDirectory * e = new KArchiveDirectory( this, dirname, d->rootDir->permissions(),
427 d->rootDir->date(), d->rootDir->user(),
428 d->rootDir->group(), TQString::null );
429 parent->addEntry( e );
430 return e; // now a directory to <path> exists
431}
432
433void KArchive::setDevice( TQIODevice * dev )
434{
435 m_dev = dev;
436}
437
438void KArchive::setRootDir( KArchiveDirectory *rootDir )
439{
440 Q_ASSERT( !d->rootDir ); // Call setRootDir only once during parsing please ;)
441 d->rootDir = rootDir;
442}
443
447KArchiveEntry::KArchiveEntry( KArchive* t, const TQString& name, int access, int date,
448 const TQString& user, const TQString& group, const
449 TQString& symlink)
450{
451 m_name = name;
452 m_access = access;
453 m_date = date;
454 m_user = user;
455 m_group = group;
456 m_symlink = symlink;
457 m_archive = t;
458
459}
460
461TQDateTime KArchiveEntry::datetime() const
462{
463 TQDateTime d;
464 d.setTime_t( m_date );
465 return d;
466}
467
471
472KArchiveFile::KArchiveFile( KArchive* t, const TQString& name, int access, int date,
473 const TQString& user, const TQString& group,
474 const TQString & symlink,
475 int pos, int size )
476 : KArchiveEntry( t, name, access, date, user, group, symlink )
477{
478 m_pos = pos;
479 m_size = size;
480}
481
482int KArchiveFile::position() const
483{
484 return m_pos;
485}
486
487int KArchiveFile::size() const
488{
489 return m_size;
490}
491
492TQByteArray KArchiveFile::data() const
493{
494 archive()->device()->at( m_pos );
495
496 // Read content
497 TQByteArray arr( m_size );
498 if ( m_size )
499 {
500 assert( arr.data() );
501 int n = archive()->device()->readBlock( arr.data(), m_size );
502 if ( n != m_size )
503 arr.resize( n );
504 }
505 return arr;
506}
507
508// ** This should be a virtual method, and this code should be in ktar.cpp
509TQIODevice *KArchiveFile::device() const
510{
511 return new KLimitedIODevice( archive()->device(), m_pos, m_size );
512}
513
514void KArchiveFile::copyTo(const TQString& dest) const
515{
516 TQFile f( dest + "/" + name() );
517 f.open( IO_ReadWrite | IO_Truncate );
518 f.writeBlock( data() );
519 f.close();
520}
521
525
526
527KArchiveDirectory::KArchiveDirectory( KArchive* t, const TQString& name, int access,
528 int date,
529 const TQString& user, const TQString& group,
530 const TQString &symlink)
531 : KArchiveEntry( t, name, access, date, user, group, symlink )
532{
533 m_entries.setAutoDelete( true );
534}
535
536TQStringList KArchiveDirectory::entries() const
537{
538 TQStringList l;
539
540 TQDictIterator<KArchiveEntry> it( m_entries );
541 for( ; it.current(); ++it )
542 l.append( it.currentKey() );
543
544 return l;
545}
546
547KArchiveEntry* KArchiveDirectory::entry( TQString name )
548 // not "const TQString & name" since we want a local copy
549 // (to remove leading slash if any)
550{
551 int pos = name.find( '/' );
552 if ( pos == 0 ) // ouch absolute path (see also KArchive::findOrCreate)
553 {
554 if (name.length()>1)
555 {
556 name = name.mid( 1 ); // remove leading slash
557 pos = name.find( '/' ); // look again
558 }
559 else // "/"
560 return this;
561 }
562 // trailing slash ? -> remove
563 if ( pos != -1 && pos == (int)name.length()-1 )
564 {
565 name = name.left( pos );
566 pos = name.find( '/' ); // look again
567 }
568 if ( pos != -1 )
569 {
570 TQString left = name.left( pos );
571 TQString right = name.mid( pos + 1 );
572
573 //kdDebug() << "KArchiveDirectory::entry left=" << left << " right=" << right << endl;
574
575 KArchiveEntry* e = m_entries[ left ];
576 if ( !e || !e->isDirectory() )
577 return 0;
578 return ((KArchiveDirectory*)e)->entry( right );
579 }
580
581 return m_entries[ name ];
582}
583
584const KArchiveEntry* KArchiveDirectory::entry( TQString name ) const
585{
586 return ((KArchiveDirectory*)this)->entry( name );
587}
588
589void KArchiveDirectory::addEntry( KArchiveEntry* entry )
590{
591 if( entry->name().isEmpty() ) {
592 return;
593 }
594 if( m_entries[ entry->name() ] ) {
595 kdWarning() << "KArchiveDirectory::addEntry: directory " << name()
596 << " has entry " << entry->name() << " already" << endl;
597 }
598 m_entries.insert( entry->name(), entry );
599}
600
601void KArchiveDirectory::copyTo(const TQString& dest, bool recursiveCopy ) const
602{
603 TQDir root;
604 const TQString destDir(TQDir(dest).absPath()); // get directory path without any "." or ".."
605
606 PosSortedPtrList fileList;
607 TQMap<int, TQString> fileToDir;
608
609 TQStringList::Iterator it;
610
611 // placeholders for iterated items
612 KArchiveDirectory* curDir;
613 TQString curDirName;
614
615 TQStringList dirEntries;
616 KArchiveEntry* curEntry;
617 KArchiveFile* curFile;
618
619
620 TQPtrStack<KArchiveDirectory> dirStack;
621 TQValueStack<TQString> dirNameStack;
622
623 dirStack.push( this ); // init stack at current directory
624 dirNameStack.push( destDir ); // ... with given path
625 do {
626 curDir = dirStack.pop();
627
628 // extract only to specified folder if it is located within archive's extraction folder
629 // otherwise put file under root position in extraction folder
630 TQString curDirName = dirNameStack.pop();
631 if (!TQDir(curDirName).absPath().startsWith(destDir)) {
632 kdWarning() << "Attempted export into folder" << curDirName
633 << "which is outside of the extraction root folder" << destDir << "."
634 << "Changing export of contained files to extraction root folder.";
635 curDirName = destDir;
636 }
637 root.mkdir(curDirName);
638
639 dirEntries = curDir->entries();
640 for ( it = dirEntries.begin(); it != dirEntries.end(); ++it ) {
641 curEntry = curDir->entry(*it);
642 if (!curEntry->symlink().isEmpty()) {
643 const TQString linkName = curDirName+'/'+curEntry->name();
644 kdDebug() << "symlink(" << curEntry->symlink() << ',' << linkName << ')';
645#ifdef Q_OS_UNIX
646 if (!::symlink(curEntry->symlink().local8Bit(), linkName.local8Bit())) {
647 kdDebug() << "symlink(" << curEntry->symlink() << ',' << linkName << ") failed:" << strerror(errno);
648 }
649#endif
650 } else {
651 if ( curEntry->isFile() ) {
652 curFile = dynamic_cast<KArchiveFile*>( curEntry );
653 if (curFile) {
654 fileList.append( curFile );
655 fileToDir.insert( curFile->position(), curDirName );
656 }
657 }
658
659 if ( curEntry->isDirectory() )
660 if ( recursiveCopy ) {
661 KArchiveDirectory *ad = dynamic_cast<KArchiveDirectory*>( curEntry );
662 if (ad) {
663 dirStack.push( ad );
664 dirNameStack.push( curDirName + "/" + curEntry->name() );
665 }
666 }
667 }
668 }
669 } while (!dirStack.isEmpty());
670
671 fileList.sort(); // sort on m_pos, so we have a linear access
672
673 KArchiveFile* f;
674 for ( f = fileList.first(); f; f = fileList.next() ) {
675 int pos = f->position();
676 f->copyTo( fileToDir[pos] );
677 }
678}
679
680void KArchive::virtual_hook( int id, void* data )
681{
682 switch (id) {
683 case VIRTUAL_WRITE_DATA: {
684 WriteDataParams* params = reinterpret_cast<WriteDataParams *>(data);
685 params->retval = writeData_impl( params->data, params->size );
686 break;
687 }
688 case VIRTUAL_WRITE_SYMLINK: {
689 WriteSymlinkParams *params = reinterpret_cast<WriteSymlinkParams *>(data);
690 params->retval = writeSymLink_impl(*params->name,*params->target,
691 *params->user,*params->group,params->perm,
692 params->atime,params->mtime,params->ctime);
693 break;
694 }
695 case VIRTUAL_WRITE_DIR: {
696 WriteDirParams *params = reinterpret_cast<WriteDirParams *>(data);
697 params->retval = writeDir_impl(*params->name,*params->user,
698 *params->group,params->perm,
699 params->atime,params->mtime,params->ctime);
700 break;
701 }
702 case VIRTUAL_WRITE_FILE: {
703 WriteFileParams *params = reinterpret_cast<WriteFileParams *>(data);
704 params->retval = writeFile_impl(*params->name,*params->user,
705 *params->group,params->size,params->perm,
706 params->atime,params->mtime,params->ctime,
707 params->data);
708 break;
709 }
710 case VIRTUAL_PREPARE_WRITING: {
711 PrepareWritingParams *params = reinterpret_cast<PrepareWritingParams *>(data);
712 params->retval = prepareWriting_impl(*params->name,*params->user,
713 *params->group,params->size,params->perm,
714 params->atime,params->mtime,params->ctime);
715 break;
716 }
717 default:
718 /*BASE::virtual_hook( id, data )*/;
719 }/*end switch*/
720}
721
722void KArchiveEntry::virtual_hook( int, void* )
723{ /*BASE::virtual_hook( id, data );*/ }
724
725void KArchiveFile::virtual_hook( int id, void* data )
726{ KArchiveEntry::virtual_hook( id, data ); }
727
728void KArchiveDirectory::virtual_hook( int id, void* data )
729{ KArchiveEntry::virtual_hook( id, data ); }
KArchiveDirectory
Represents a directory entry in a KArchive.
Definition: karchive.h:574
KArchiveDirectory::entries
TQStringList entries() const
Returns a list of sub-entries.
Definition: karchive.cpp:536
KArchiveDirectory::KArchiveDirectory
KArchiveDirectory(KArchive *archive, const TQString &name, int access, int date, const TQString &user, const TQString &group, const TQString &symlink)
Creates a new directory entry.
Definition: karchive.cpp:527
KArchiveDirectory::copyTo
void copyTo(const TQString &dest, bool recursive=true) const
Extracts all entries in this archive directory to the directory dest.
Definition: karchive.cpp:601
KArchiveDirectory::entry
KArchiveEntry * entry(TQString name)
Returns the entry with the given name.
Definition: karchive.cpp:547
KArchiveEntry
A base class for entries in an KArchive.
Definition: karchive.h:396
KArchiveEntry::isDirectory
virtual bool isDirectory() const
Checks whether the entry is a directory.
Definition: karchive.h:464
KArchiveEntry::date
int date() const
Creation date of the file.
Definition: karchive.h:424
KArchiveEntry::group
TQString group() const
Group of the user who created the file.
Definition: karchive.h:446
KArchiveEntry::user
TQString user() const
User who created the file.
Definition: karchive.h:441
KArchiveEntry::isFile
virtual bool isFile() const
Checks whether the entry is a file.
Definition: karchive.h:458
KArchiveEntry::name
TQString name() const
Name of the file without path.
Definition: karchive.h:430
KArchiveEntry::datetime
TQDateTime datetime() const
Creation date of the file.
Definition: karchive.cpp:461
KArchiveEntry::symlink
TQString symlink() const
Symlink if there is one.
Definition: karchive.h:452
KArchiveEntry::KArchiveEntry
KArchiveEntry(KArchive *archive, const TQString &name, int access, int date, const TQString &user, const TQString &group, const TQString &symlink)
Creates a new entry.
Definition: karchive.cpp:447
KArchiveFile
Represents a file entry in a KArchive.
Definition: karchive.h:491
KArchiveFile::copyTo
void copyTo(const TQString &dest) const
Extracts the file to the directory dest.
Definition: karchive.cpp:514
KArchiveFile::KArchiveFile
KArchiveFile(KArchive *archive, const TQString &name, int access, int date, const TQString &user, const TQString &group, const TQString &symlink, int pos, int size)
Creates a new file entry.
Definition: karchive.cpp:472
KArchiveFile::size
int size() const
Size of the data.
Definition: karchive.cpp:487
KArchiveFile::device
TQIODevice * device() const
This method returns TQIODevice (internal class: KLimitedIODevice) on top of the underlying TQIODevice...
Definition: karchive.cpp:509
KArchiveFile::data
virtual TQByteArray data() const
Returns the data of the file.
Definition: karchive.cpp:492
KArchiveFile::position
int position() const
Position of the data in the [uncompressed] archive.
Definition: karchive.cpp:482
KArchive
KArchive is a base class for reading and writing archives.
Definition: karchive.h:43
KArchive::writeDir
virtual bool writeDir(const TQString &name, const TQString &user, const TQString &group)=0
If an archive is opened for writing then you can add new directories using this function.
KArchive::rootDir
virtual KArchiveDirectory * rootDir()
Retrieves or create the root directory.
Definition: karchive.cpp:368
KArchive::open
virtual bool open(int mode)
Opens the archive for reading or writing.
Definition: karchive.cpp:91
KArchive::KArchive
KArchive(TQIODevice *dev)
Base constructor (protected since this is a pure virtual class).
Definition: karchive.cpp:75
KArchive::addLocalFile
bool addLocalFile(const TQString &fileName, const TQString &destName)
Writes a local file into the archive.
Definition: karchive.cpp:136
KArchive::findOrCreate
KArchiveDirectory * findOrCreate(const TQString &path)
Ensures that path exists, create otherwise.
Definition: karchive.cpp:383
KArchive::close
virtual void close()
Closes the archive.
Definition: karchive.cpp:108
KArchive::addLocalDirectory
bool addLocalDirectory(const TQString &path, const TQString &destName)
Writes a local directory into the archive, including all its contents, recursively.
Definition: karchive.cpp:200
KArchive::closeArchive
virtual bool closeArchive()=0
Closes the archive.
KArchive::directory
const KArchiveDirectory * directory() const
If an archive is opened for reading, then the contents of the archive can be accessed via this functi...
Definition: karchive.cpp:129
KArchive::mode
int mode() const
Returns the mode in which the archive was opened.
Definition: karchive.h:90
KArchive::device
TQIODevice * device() const
The underlying device.
Definition: karchive.h:96
KArchive::doneWriting
virtual bool doneWriting(uint size)=0
Call doneWriting after writing the data.
KArchive::openArchive
virtual bool openArchive(int mode)=0
Opens an archive for reading or writing.
KArchive::closeSucceeded
bool closeSucceeded() const
Use to check if close had any problem.
Definition: karchive.cpp:124
KArchive::writeData
bool writeData(const char *data, uint size)
Write data into the current file - to be called after calling prepareWriting.
Definition: karchive.cpp:353
KArchive::writeSymLink
bool writeSymLink(const TQString &name, const TQString &target, const TQString &user, const TQString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
Writes a symbolic link to the archive if the archive must be opened for writing.
Definition: karchive.cpp:327
KArchive::prepareWriting
virtual bool prepareWriting(const TQString &name, const TQString &user, const TQString &group, uint size)=0
Here's another way of writing a file into an archive: Call prepareWriting, then call writeData() as m...
KArchive::writeFile
virtual bool writeFile(const TQString &name, const TQString &user, const TQString &group, uint size, const char *data)
If an archive is opened for writing then you can add a new file using this function.
Definition: karchive.cpp:228
KLimitedIODevice
A readonly device that reads from an underlying device from a given point to another (e....
Definition: klimitediodevice.h:32

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.9.4
This website is maintained by Timothy Pearson.