You are not logged in.

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: 24

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.