You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, July 12th 2004, 12:41pm

anyone familiar with KIO::NetAccess???

Hi, first of all I'm new on this. I need help because I don't know why allmost all KIO::NetAccess functions fails. I get segfault when I try to use them. The only one that seems to work is KIO::NetAccess::exists.

I'm trying to delete a local file with this code:

char* c = "file:/home/marcos/public_html/test2.txt";
KURL src = KURL( c );

if ( src.isValid() && KIO::NetAccess::exists(src, false, NULL) ) {
KIO::NetAccess::del(src, NULL);
cout << "file was deleted \n";
} else {
cout << "error, kurl is not valid or I can't access to the file \n";
}

I'm getting the segfault when running KIO::NetAccess::del(src, NULL); line, but KIO::NetAccess::exists(src, false, NULL) works fine. What I'm doing wrong?

2

Monday, July 12th 2004, 1:38pm

I have improvement the code, but the error is there


char* c = "file:/home/marcos/public_html/test2.txt";
QString qstr(c);
KURL src(qstr);

if ( src.isValid() && KIO::NetAccess::exists(src, false, 0) ) {
KIO::NetAccess::del(src, 0);
kdDebug() << "all ok \n";
} else {
kdDebug() << "something fails \n";
}

f_edemar

Beginner

Posts: 14

Location: Sweden

  • Send private message

3

Monday, July 12th 2004, 2:08pm

Maybe it should be

Source code

1
KIO::NetAccess::exists(src, true, 0)

Instead of

Source code

1
KIO::NetAccess::exists(src, false, 0)


PS:
You don't need to define three variables, just write

Source code

1
KURL src( "file:/home/marcos/public_html/test2.txt");

as KURL has a constructor which takes char * as argument.