Remove tdeio_tar since it is already provided by tdebase.
Krusader's tdeio_tar contains a couple of extra functions compared to
tdebase's tdeio_tar, but they do not work at all.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 390ce2034f)
r14.1.x
parent
c84a18a92d
commit
c29ac1aeec
@ -1,21 +0,0 @@
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
|
||||
##### tdeio_tar (module)
|
||||
|
||||
tde_add_kpart( tdeio_tar AUTOMOC
|
||||
SOURCES tar.cpp
|
||||
LINK tdecore-shared tdeio-shared
|
||||
DESTINATION ${PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
|
||||
##### other data
|
||||
|
||||
tde_create_translated_desktop(
|
||||
SOURCE ar.protocol tar.protocol zip.protocol
|
||||
DESTINATION ${SERVICES_INSTALL_DIR}
|
||||
)
|
||||
@ -1,22 +0,0 @@
|
||||
## Makefile.am of tdebase/tdeioslave/tar
|
||||
|
||||
INCLUDES = $(all_includes)
|
||||
AM_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_TQT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor
|
||||
METASOURCES = AUTO
|
||||
|
||||
kde_module_LTLIBRARIES = tdeio_tar.la
|
||||
|
||||
tdeio_tar_la_SOURCES = tar.cpp
|
||||
tdeio_tar_la_LIBADD = $(LIB_TDESYCOCA)
|
||||
tdeio_tar_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
|
||||
|
||||
check_PROGRAMS = ktartest
|
||||
|
||||
ktartest_SOURCES = ktartest.cpp
|
||||
ktartest_LDADD = $(LIB_TDESYCOCA)
|
||||
|
||||
noinst_HEADERS = tar.h
|
||||
|
||||
kdelnk_DATA = tar.protocol ar.protocol zip.protocol
|
||||
kdelnkdir = $(kde_servicesdir)
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
[Protocol]
|
||||
exec=tdeio_tar
|
||||
protocol=ar
|
||||
mimetype=application/x-archive
|
||||
input=filesystem
|
||||
output=filesystem
|
||||
listing=Name,Type,Size,Date,Access,Owner,Group,Link
|
||||
reading=true
|
||||
source=true
|
||||
X-DocPath=tdeioslave/ar/index.html
|
||||
Icon=ar
|
||||
Class=:local
|
||||
@ -1,201 +0,0 @@
|
||||
#include "ktar.h"
|
||||
#include <stdio.h>
|
||||
#include <tqfile.h>
|
||||
#include <tdeinstance.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
void recursive_print( const KTarDirectory * dir, const TQString & path )
|
||||
{
|
||||
TQStringList l = dir->entries();
|
||||
TQStringList::Iterator it = l.begin();
|
||||
for( ; it != l.end(); ++it )
|
||||
{
|
||||
const KTarEntry* entry = dir->entry( (*it) );
|
||||
printf("mode=%07o %s %s %s%s\n", entry->permissions(), entry->user().latin1(), entry->group().latin1(), path.latin1(), (*it).latin1());
|
||||
if (entry->isDirectory())
|
||||
recursive_print( (KTarDirectory *)entry, path+(*it)+"/" );
|
||||
}
|
||||
}
|
||||
|
||||
static void usage()
|
||||
{
|
||||
printf("\n"
|
||||
" Usage :\n"
|
||||
" ./ktartest list /path/to/existing_file.tar.gz tests listing an existing tar.gz\n"
|
||||
" ./ktartest get /path/to/existing_file.tar.gz filename tests extracting a file.\n"
|
||||
" ./ktartest readwrite newfile.tar.gz will create the tar.gz, then close and reopen it.\n"
|
||||
" ./ktartest maxlength newfile.tar.gz tests the maximum filename length allowed.\n"
|
||||
" ./ktartest bytearray /path/to/existing_file.tar.gz tests KTarData\n");
|
||||
}
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
if (argc < 3)
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
TDEInstance instance("ktartest");
|
||||
|
||||
TQString command = argv[1];
|
||||
kdDebug() << "main: command=" << command << endl;
|
||||
if ( command == "list" )
|
||||
{
|
||||
KTarGz tar( argv[2] );
|
||||
|
||||
if ( !tar.open( IO_ReadOnly ) )
|
||||
{
|
||||
printf("Could not open %s for reading\n", argv[1] );
|
||||
return 1;
|
||||
}
|
||||
|
||||
const KTarDirectory* dir = tar.directory();
|
||||
|
||||
//printf("calling recursive_print\n");
|
||||
recursive_print( dir, "" );
|
||||
//printf("recursive_print called\n");
|
||||
|
||||
tar.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if ( command == "get" )
|
||||
{
|
||||
if ( argc != 4 )
|
||||
{
|
||||
usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
KTarGz tar( argv[2] );
|
||||
|
||||
if ( !tar.open( IO_ReadOnly ) )
|
||||
{
|
||||
printf("Could not open %s for reading\n", argv[1] );
|
||||
return 1;
|
||||
}
|
||||
|
||||
const KTarDirectory* dir = tar.directory();
|
||||
|
||||
const KTarEntry* e = dir->entry( argv[3] );
|
||||
Q_ASSERT( e && e->isFile() );
|
||||
const KTarFile* f = (KTarFile*)e;
|
||||
|
||||
TQByteArray arr( f->data() );
|
||||
printf("SIZE=%i\n",arr.size() );
|
||||
TQString str( arr );
|
||||
printf("DATA=%s\n", str.latin1());
|
||||
|
||||
/*
|
||||
// This is what KGzipDev::readAll could do, if TQIODevice::readAll was virtual....
|
||||
TQByteArray array(1024);
|
||||
int n;
|
||||
while ( ( n = dev.readBlock( array.data(), array.size() ) ) )
|
||||
{
|
||||
kdDebug() << "readBlock returned " << n << endl << endl;
|
||||
TQCString s(array,n+1); // Terminate with 0 before printing
|
||||
printf("%s", s.data());
|
||||
}
|
||||
dev.close();
|
||||
*/
|
||||
|
||||
|
||||
tar.close();
|
||||
}
|
||||
else if (command == "readwrite" )
|
||||
{
|
||||
kdDebug() << " --- readwrite --- " << endl;
|
||||
KTarGz tar( argv[2] );
|
||||
|
||||
if ( !tar.open( IO_WriteOnly ) )
|
||||
{
|
||||
printf("Could not open %s for writing\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
tar.writeFile( "empty", "weis", "users", 0, "" );
|
||||
tar.writeFile( "test1", "weis", "users", 5, "Hallo" );
|
||||
tar.writeFile( "test2", "weis", "users", 8, "Hallo Du" );
|
||||
tar.writeFile( "mydir/test3", "weis", "users", 13, "Noch so einer" );
|
||||
tar.writeFile( "my/dir/test3", "dfaure", "hackers", 29, "I don't speak German (David)" );
|
||||
|
||||
#define SIZE1 100
|
||||
// Now a medium file : 100 null bytes
|
||||
char medium[ SIZE1 ];
|
||||
memset( medium, 0, SIZE1 );
|
||||
tar.writeFile( "mediumfile", "user", "group", SIZE1, medium );
|
||||
// Another one, with an absolute path
|
||||
tar.writeFile( "/dir/subdir/mediumfile2", "user", "group", SIZE1, medium );
|
||||
|
||||
// Now a huge file : 20000 null bytes
|
||||
int n = 20000;
|
||||
char * huge = new char[ n ];
|
||||
memset( huge, 0, n );
|
||||
tar.writeFile( "hugefile", "user", "group", n, huge );
|
||||
delete [] huge;
|
||||
|
||||
tar.close();
|
||||
|
||||
printf("-----------------------\n");
|
||||
|
||||
if ( !tar.open( IO_ReadOnly ) )
|
||||
{
|
||||
printf("Could not open %s for reading\n", argv[1] );
|
||||
return 1;
|
||||
}
|
||||
|
||||
const KTarDirectory* dir = tar.directory();
|
||||
recursive_print(dir, "");
|
||||
|
||||
const KTarEntry* e = dir->entry( "mydir/test3" );
|
||||
Q_ASSERT( e && e->isFile() );
|
||||
const KTarFile* f = (KTarFile*)e;
|
||||
|
||||
TQByteArray arr( f->data() );
|
||||
printf("SIZE=%i\n",arr.size() );
|
||||
TQString str( arr );
|
||||
printf("DATA=%s\n", str.latin1());
|
||||
|
||||
tar.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if ( command == "maxlength" )
|
||||
{
|
||||
KTarGz tar( argv[2] );
|
||||
|
||||
if ( !tar.open( IO_WriteOnly ) )
|
||||
{
|
||||
printf("Could not open %s for writing\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
// Generate long filenames of each possible length bigger than 98...
|
||||
for (int i = 98; i < 500 ; i++ )
|
||||
{
|
||||
TQString str, num;
|
||||
str.fill( 'a', i-10 );
|
||||
num.setNum( i );
|
||||
num = num.rightJustify( 10, '0' );
|
||||
tar.writeFile( str+num, "testu", "testg", 3, "hum" );
|
||||
}
|
||||
// Result of this test : it fails at 482 (instead of 154 previously).
|
||||
// Ok, I think we can do with that :)
|
||||
tar.close();
|
||||
printf("Now run 'tar tvzf %s'\n", argv[2]);
|
||||
return 0;
|
||||
}
|
||||
else if ( command == "bytearray" )
|
||||
{
|
||||
TQFile file( argv[2] );
|
||||
if ( !file.open( IO_ReadOnly ) )
|
||||
return 1;
|
||||
KTarGz tar( &file );
|
||||
tar.open( IO_ReadOnly );
|
||||
const KTarDirectory* dir = tar.directory();
|
||||
recursive_print( dir, "" );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
printf("Unknown command\n");
|
||||
}
|
||||
|
||||
@ -1,482 +0,0 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <tqfile.h>
|
||||
#include <tqfileinfo.h>
|
||||
#include <tqptrqueue.h>
|
||||
#include <kurl.h>
|
||||
#include <kdebug.h>
|
||||
#include <tdeinstance.h>
|
||||
#include <ktar.h>
|
||||
#include <kzip.h>
|
||||
#include <kar.h>
|
||||
#include <kmimemagic.h>
|
||||
#include <tdelocale.h>
|
||||
#include <tdeversion.h>
|
||||
|
||||
#include <errno.h> // to be removed
|
||||
|
||||
#include "tar.h"
|
||||
|
||||
using namespace TDEIO;
|
||||
|
||||
#if KDE_IS_VERSION(3,4,0)
|
||||
extern "C" { int TDE_EXPORT kdemain( int argc, char **argv ); }
|
||||
#else
|
||||
extern "C" { int kdemain( int argc, char **argv ); }
|
||||
#endif
|
||||
|
||||
int kdemain( int argc, char **argv ) {
|
||||
TDEInstance instance( "tdeio_tar" );
|
||||
|
||||
kdDebug( 7109 ) << "Starting " << getpid() << endl;
|
||||
|
||||
if ( argc != 4 ) {
|
||||
fprintf( stderr, "Usage: tdeio_tar protocol domain-socket1 domain-socket2\n" );
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
ArchiveProtocol slave( argv[ 2 ], argv[ 3 ] );
|
||||
slave.dispatchLoop();
|
||||
|
||||
kdDebug( 7109 ) << "Done" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ArchiveProtocol::ArchiveProtocol( const TQCString &pool, const TQCString &app ) : SlaveBase( "tar", pool, app ) {
|
||||
kdDebug( 7109 ) << "ArchiveProtocol::ArchiveProtocol" << endl;
|
||||
m_archiveFile = 0L;
|
||||
}
|
||||
|
||||
ArchiveProtocol::~ArchiveProtocol() {
|
||||
delete m_archiveFile;
|
||||
}
|
||||
|
||||
void ArchiveProtocol::put( const KURL& url, int, bool, bool resume ){
|
||||
if( resume ){
|
||||
error(ERR_UNSUPPORTED_ACTION,i18n("This protocol does not support resuming") );
|
||||
return;
|
||||
}
|
||||
|
||||
TQByteArray tempBuffer;
|
||||
TQPtrQueue<TQByteArray> buffer;
|
||||
buffer.setAutoDelete(true);
|
||||
int readResult=0;
|
||||
int size = 0;
|
||||
TQByteArray* temp;
|
||||
do{
|
||||
dataReq();
|
||||
temp = new TQByteArray();
|
||||
readResult = readData(*temp);
|
||||
buffer.enqueue(temp);
|
||||
size += temp->size();
|
||||
} while( readResult > 0 );
|
||||
|
||||
TQString filename = url.path().mid(m_archiveName.length()+1);
|
||||
|
||||
if( !m_archiveFile->prepareWriting(filename,user,group,size) ){
|
||||
error(ERR_UNSUPPORTED_ACTION,
|
||||
i18n("Writing to %1 is not supported").arg(filename) );
|
||||
return;
|
||||
}
|
||||
while( (temp=buffer.dequeue()) ){
|
||||
m_archiveFile->writeData(temp->data(),temp->size());
|
||||
}
|
||||
m_archiveFile->doneWriting(size);
|
||||
|
||||
finished();
|
||||
}
|
||||
|
||||
void ArchiveProtocol::mkdir(const KURL& url,int){
|
||||
TQString filename = url.path().mid(m_archiveName.length()+1);
|
||||
m_archiveFile->writeDir(filename,user,group);
|
||||
finished();
|
||||
}
|
||||
|
||||
bool ArchiveProtocol::checkNewFile( const KURL & url, TQString & path ) {
|
||||
TQString fullPath = url.path();
|
||||
kdDebug( 7109 ) << "ArchiveProtocol::checkNewFile " << fullPath << endl;
|
||||
|
||||
|
||||
// Are we already looking at that file ?
|
||||
if ( m_archiveFile && m_archiveName == fullPath.left( m_archiveName.length() ) ) {
|
||||
// Has it changed ?
|
||||
struct stat statbuf;
|
||||
if ( ::stat( TQFile::encodeName( m_archiveName ), &statbuf ) == 0 ) {
|
||||
if ( m_mtime == statbuf.st_mtime ) {
|
||||
path = fullPath.mid( m_archiveName.length() );
|
||||
kdDebug( 7109 ) << "ArchiveProtocol::checkNewFile returning " << path << endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
kdDebug( 7109 ) << "Need to open a new file" << endl;
|
||||
|
||||
// Close previous file
|
||||
if ( m_archiveFile ) {
|
||||
m_archiveFile->close();
|
||||
delete m_archiveFile;
|
||||
m_archiveFile = 0L;
|
||||
}
|
||||
|
||||
// Find where the tar file is in the full path
|
||||
int pos = 0;
|
||||
TQString archiveFile;
|
||||
path = TQString();
|
||||
|
||||
int len = fullPath.length();
|
||||
if ( len != 0 && fullPath[ len - 1 ] != '/' )
|
||||
fullPath += '/';
|
||||
|
||||
kdDebug( 7109 ) << "the full path is " << fullPath << endl;
|
||||
while ( ( pos = fullPath.find( '/', pos + 1 ) ) != -1 ) {
|
||||
TQString tryPath = fullPath.left( pos );
|
||||
kdDebug( 7109 ) << fullPath << " trying " << tryPath << endl;
|
||||
struct stat statbuf;
|
||||
if ( ::stat( TQFile::encodeName( tryPath ), &statbuf ) == 0 && !S_ISDIR( statbuf.st_mode ) ) {
|
||||
archiveFile = tryPath;
|
||||
m_mtime = statbuf.st_mtime;
|
||||
user = TQFileInfo(archiveFile).owner();
|
||||
group = TQFileInfo(archiveFile).group();
|
||||
path = fullPath.mid( pos + 1 );
|
||||
kdDebug( 7109 ) << "fullPath=" << fullPath << " path=" << path << endl;
|
||||
len = path.length();
|
||||
if ( len > 1 ) {
|
||||
if ( path[ len - 1 ] == '/' )
|
||||
path.truncate( len - 1 );
|
||||
} else
|
||||
path = TQString::fromLatin1( "/" );
|
||||
kdDebug( 7109 ) << "Found. archiveFile=" << archiveFile << " path=" << path << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( archiveFile.isEmpty() ) {
|
||||
kdDebug( 7109 ) << "ArchiveProtocol::checkNewFile: not found" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Open new file
|
||||
if ( url.protocol() == "tar" ) {
|
||||
kdDebug( 7109 ) << "Opening KTar on " << archiveFile << endl;
|
||||
m_archiveFile = new KTar( archiveFile );
|
||||
} else if ( url.protocol() == "ar" ) {
|
||||
kdDebug( 7109 ) << "Opening KAr on " << archiveFile << endl;
|
||||
m_archiveFile = new KAr( archiveFile );
|
||||
} else if ( url.protocol() == "zip" ) {
|
||||
kdDebug( 7109 ) << "Opening KZip on " << archiveFile << endl;
|
||||
m_archiveFile = new KZip( archiveFile );
|
||||
} else {
|
||||
kdWarning( 7109 ) << "Protocol " << url.protocol() << " not supported by this IOSlave" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !m_archiveFile->open( IO_ReadWrite ) ) {
|
||||
kdDebug( 7109 ) << "Opening " << archiveFile << "failed." << endl;
|
||||
delete m_archiveFile;
|
||||
m_archiveFile = 0L;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_archiveName = archiveFile;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ArchiveProtocol::createUDSEntry( const KArchiveEntry * archiveEntry, UDSEntry & entry ) {
|
||||
UDSAtom atom;
|
||||
entry.clear();
|
||||
atom.m_uds = UDS_NAME;
|
||||
atom.m_str = archiveEntry->name();
|
||||
entry.append( atom );
|
||||
|
||||
atom.m_uds = UDS_FILE_TYPE;
|
||||
atom.m_long = archiveEntry->permissions() & S_IFMT; // keep file type only
|
||||
entry.append( atom );
|
||||
|
||||
atom.m_uds = UDS_SIZE;
|
||||
atom.m_long = archiveEntry->isFile() ? ( ( KArchiveFile * ) archiveEntry ) ->size() : 0L ;
|
||||
entry.append( atom );
|
||||
|
||||
atom.m_uds = UDS_MODIFICATION_TIME;
|
||||
atom.m_long = archiveEntry->date();
|
||||
entry.append( atom );
|
||||
|
||||
atom.m_uds = UDS_ACCESS;
|
||||
atom.m_long = archiveEntry->permissions() & 07777; // keep permissions only
|
||||
entry.append( atom );
|
||||
|
||||
atom.m_uds = UDS_USER;
|
||||
atom.m_str = archiveEntry->user();
|
||||
entry.append( atom );
|
||||
|
||||
atom.m_uds = UDS_GROUP;
|
||||
atom.m_str = archiveEntry->group();
|
||||
entry.append( atom );
|
||||
|
||||
atom.m_uds = UDS_LINK_DEST;
|
||||
atom.m_str = archiveEntry->symlink();
|
||||
entry.append( atom );
|
||||
}
|
||||
|
||||
void ArchiveProtocol::listDir( const KURL & url ) {
|
||||
kdDebug( 7109 ) << "ArchiveProtocol::listDir " << url.url() << endl;
|
||||
|
||||
TQString path;
|
||||
if ( !checkNewFile( url, path ) ) {
|
||||
TQCString _path( TQFile::encodeName( url.path() ) );
|
||||
kdDebug( 7109 ) << "Checking (stat) on " << _path << endl;
|
||||
struct stat buff;
|
||||
if ( ::stat( _path.data(), &buff ) == -1 || !S_ISDIR( buff.st_mode ) ) {
|
||||
error( TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
|
||||
return ;
|
||||
}
|
||||
// It's a real dir -> redirect
|
||||
KURL redir;
|
||||
redir.setPath( url.path() );
|
||||
kdDebug( 7109 ) << "Ok, redirection to " << redir.url() << endl;
|
||||
redirection( redir );
|
||||
finished();
|
||||
// And let go of the tar file - for people who want to unmount a cdrom after that
|
||||
delete m_archiveFile;
|
||||
m_archiveFile = 0L;
|
||||
return ;
|
||||
}
|
||||
|
||||
if ( path.isEmpty() ) {
|
||||
KURL redir( url.protocol() + TQString::fromLatin1( ":/" ) );
|
||||
kdDebug( 7109 ) << "url.path()==" << url.path() << endl;
|
||||
redir.setPath( url.path() + TQString::fromLatin1( "/" ) );
|
||||
kdDebug( 7109 ) << "ArchiveProtocol::listDir: redirection " << redir.url() << endl;
|
||||
redirection( redir );
|
||||
finished();
|
||||
return ;
|
||||
}
|
||||
|
||||
kdDebug( 7109 ) << "checkNewFile done" << endl;
|
||||
const KArchiveDirectory* root = m_archiveFile->directory();
|
||||
const KArchiveDirectory* dir;
|
||||
if ( !path.isEmpty() && path != "/" ) {
|
||||
kdDebug( 7109 ) << TQString( "Looking for entry %1" ).arg( path ) << endl;
|
||||
const KArchiveEntry* e = root->entry( path );
|
||||
if ( !e ) {
|
||||
error( TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
|
||||
return ;
|
||||
}
|
||||
if ( ! e->isDirectory() ) {
|
||||
error( TDEIO::ERR_IS_FILE, url.prettyURL() );
|
||||
return ;
|
||||
}
|
||||
dir = ( KArchiveDirectory* ) e;
|
||||
} else {
|
||||
dir = root;
|
||||
}
|
||||
|
||||
TQStringList l = dir->entries();
|
||||
totalSize( l.count() );
|
||||
|
||||
UDSEntry entry;
|
||||
TQStringList::Iterator it = l.begin();
|
||||
for ( ; it != l.end(); ++it ) {
|
||||
kdDebug( 7109 ) << ( *it ) << endl;
|
||||
const KArchiveEntry* archiveEntry = dir->entry( ( *it ) );
|
||||
|
||||
createUDSEntry( archiveEntry, entry );
|
||||
|
||||
listEntry( entry, false );
|
||||
}
|
||||
|
||||
listEntry( entry, true ); // ready
|
||||
|
||||
finished();
|
||||
|
||||
kdDebug( 7109 ) << "ArchiveProtocol::listDir done" << endl;
|
||||
}
|
||||
|
||||
void ArchiveProtocol::stat( const KURL & url ) {
|
||||
TQString path;
|
||||
UDSEntry entry;
|
||||
if ( !checkNewFile( url, path ) ) {
|
||||
// We may be looking at a real directory - this happens
|
||||
// when pressing up after being in the root of an archive
|
||||
TQCString _path( TQFile::encodeName( url.path() ) );
|
||||
kdDebug( 7109 ) << "ArchiveProtocol::stat (stat) on " << _path << endl;
|
||||
struct stat buff;
|
||||
if ( ::stat( _path.data(), &buff ) == -1 || !S_ISDIR( buff.st_mode ) ) {
|
||||
kdDebug( 7109 ) << "isdir=" << S_ISDIR( buff.st_mode ) << " errno=" << strerror( errno ) << endl;
|
||||
error( TDEIO::ERR_DOES_NOT_EXIST, url.path() );
|
||||
return ;
|
||||
}
|
||||
// Real directory. Return just enough information for KRun to work
|
||||
UDSAtom atom;
|
||||
atom.m_uds = TDEIO::UDS_NAME;
|
||||
atom.m_str = url.fileName();
|
||||
entry.append( atom );
|
||||
kdDebug( 7109 ) << "ArchiveProtocol::stat returning name=" << url.fileName() << endl;
|
||||
|
||||
atom.m_uds = TDEIO::UDS_FILE_TYPE;
|
||||
atom.m_long = buff.st_mode & S_IFMT;
|
||||
entry.append( atom );
|
||||
|
||||
statEntry( entry );
|
||||
|
||||
finished();
|
||||
|
||||
// And let go of the tar file - for people who want to unmount a cdrom after that
|
||||
delete m_archiveFile;
|
||||
m_archiveFile = 0L;
|
||||
return ;
|
||||
}
|
||||
|
||||
const KArchiveDirectory* root = m_archiveFile->directory();
|
||||
const KArchiveEntry* archiveEntry;
|
||||
if ( path.isEmpty() ) {
|
||||
path = TQString::fromLatin1( "/" );
|
||||
archiveEntry = root;
|
||||
} else {
|
||||
archiveEntry = root->entry( path );
|
||||
}
|
||||
if ( !archiveEntry ) {
|
||||
error( TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
|
||||
return ;
|
||||
}
|
||||
|
||||
createUDSEntry( archiveEntry, entry );
|
||||
statEntry( entry );
|
||||
|
||||
finished();
|
||||
}
|
||||
|
||||
void ArchiveProtocol::get( const KURL & url ) {
|
||||
kdDebug( 7109 ) << "ArchiveProtocol::get" << url.url() << endl;
|
||||
|
||||
TQString path;
|
||||
if ( !checkNewFile( url, path ) ) {
|
||||
error( TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
|
||||
return ;
|
||||
}
|
||||
|
||||
const KArchiveDirectory* root = m_archiveFile->directory();
|
||||
const KArchiveEntry* archiveEntry = root->entry( path );
|
||||
|
||||
if ( !archiveEntry ) {
|
||||
error( TDEIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
|
||||
return ;
|
||||
}
|
||||
if ( archiveEntry->isDirectory() ) {
|
||||
error( TDEIO::ERR_IS_DIRECTORY, url.prettyURL() );
|
||||
return ;
|
||||
}
|
||||
const KArchiveFile* archiveFileEntry = static_cast<const KArchiveFile *>( archiveEntry );
|
||||
if ( !archiveEntry->symlink().isEmpty() ) {
|
||||
kdDebug( 7109 ) << "Redirection to " << archiveEntry->symlink() << endl;
|
||||
KURL realURL( url, archiveEntry->symlink() );
|
||||
kdDebug( 7109 ) << "realURL= " << realURL.url() << endl;
|
||||
redirection( realURL );
|
||||
finished();
|
||||
return ;
|
||||
}
|
||||
|
||||
totalSize( archiveFileEntry->size() );
|
||||
|
||||
TQByteArray completeData = archiveFileEntry->data();
|
||||
|
||||
KMimeMagicResult * result = KMimeMagic::self() ->findBufferFileType( completeData, path );
|
||||
kdDebug( 7109 ) << "Emitting mimetype " << result->mimeType() << endl;
|
||||
mimeType( result->mimeType() );
|
||||
|
||||
data( completeData );
|
||||
|
||||
processedSize( archiveFileEntry->size() );
|
||||
data( TQByteArray() );
|
||||
|
||||
finished();
|
||||
}
|
||||
|
||||
/*
|
||||
In case someone wonders how the old filter stuff looked like : :)
|
||||
void TARProtocol::slotData(void *_p, int _len)
|
||||
{
|
||||
switch (m_cmd) {
|
||||
case CMD_PUT:
|
||||
assert(m_pFilter);
|
||||
m_pFilter->send(_p, _len);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TARProtocol::slotDataEnd()
|
||||
{
|
||||
switch (m_cmd) {
|
||||
case CMD_PUT:
|
||||
assert(m_pFilter && m_pJob);
|
||||
m_pFilter->finish();
|
||||
m_pJob->dataEnd();
|
||||
m_cmd = CMD_NONE;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TARProtocol::jobData(void *_p, int _len)
|
||||
{
|
||||
switch (m_cmd) {
|
||||
case CMD_GET:
|
||||
assert(m_pFilter);
|
||||
m_pFilter->send(_p, _len);
|
||||
break;
|
||||
case CMD_COPY:
|
||||
assert(m_pFilter);
|
||||
m_pFilter->send(_p, _len);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void TARProtocol::jobDataEnd()
|
||||
{
|
||||
switch (m_cmd) {
|
||||
case CMD_GET:
|
||||
assert(m_pFilter);
|
||||
m_pFilter->finish();
|
||||
dataEnd();
|
||||
break;
|
||||
case CMD_COPY:
|
||||
assert(m_pFilter);
|
||||
m_pFilter->finish();
|
||||
m_pJob->dataEnd();
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void TARProtocol::filterData(void *_p, int _len)
|
||||
{
|
||||
debug("void TARProtocol::filterData");
|
||||
switch (m_cmd) {
|
||||
case CMD_GET:
|
||||
data(_p, _len);
|
||||
break;
|
||||
case CMD_PUT:
|
||||
assert (m_pJob);
|
||||
m_pJob->data(_p, _len);
|
||||
break;
|
||||
case CMD_COPY:
|
||||
assert(m_pJob);
|
||||
m_pJob->data(_p, _len);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
/* This file is part of the KDE libraries
|
||||
Copyright (C) 2000 David Faure <faure@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _TAR_H
|
||||
#define _TAR_H
|
||||
|
||||
#include <tdeio/slavebase.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
class ArchiveProtocol : public TDEIO::SlaveBase {
|
||||
public:
|
||||
ArchiveProtocol( const TQCString &pool, const TQCString &app );
|
||||
virtual ~ArchiveProtocol();
|
||||
|
||||
virtual void listDir( const KURL & url );
|
||||
virtual void stat( const KURL & url );
|
||||
virtual void get( const KURL & url );
|
||||
virtual void put( const KURL& url, int permissions, bool overwrite, bool resume );
|
||||
virtual void mkdir(const KURL& url,int permissions);
|
||||
|
||||
protected:
|
||||
void createUDSEntry( const KArchiveEntry * tarEntry, TDEIO::UDSEntry & entry );
|
||||
bool checkNewFile( const KURL & url, TQString & path );
|
||||
|
||||
KArchive * m_archiveFile;
|
||||
TQString m_archiveName;
|
||||
TQString user;
|
||||
TQString group;
|
||||
time_t m_mtime;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,12 +0,0 @@
|
||||
[Protocol]
|
||||
exec=tdeio_tar
|
||||
protocol=tar
|
||||
mimetype=application/x-tar
|
||||
input=filesystem
|
||||
output=filesystem
|
||||
listing=Name,Type,Size,Date,Access,Owner,Group,Link
|
||||
reading=true
|
||||
source=true
|
||||
X-DocPath=tdeioslave/tar/index.html
|
||||
Icon=application-x-tar
|
||||
Class=:local
|
||||
@ -1,12 +0,0 @@
|
||||
[Protocol]
|
||||
exec=tdeio_tar
|
||||
protocol=zip
|
||||
mimetype=application/x-zip
|
||||
input=filesystem
|
||||
output=filesystem
|
||||
listing=Name,Type,Size,Date,Access,Owner,Group,Link
|
||||
reading=true
|
||||
source=true
|
||||
X-DocPath=tdeioslave/zip/index.html
|
||||
Icon=application-vnd.tde.overlay.zip
|
||||
Class=:local
|
||||
Loading…
Reference in New Issue