[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fwd: how to delete a directory and its subdirectories with libssh ?
[Thread Prev] | [Thread Next]
- Subject: Re: Fwd: how to delete a directory and its subdirectories with libssh ?
- From: Stéphane Lemoine <slemoine@xxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 13 Apr 2016 10:07:11 +0200
- To: libssh@xxxxxxxxxx
OK thanks you tilo, you are right and you solved my problem I have built the full path and it is now OK Thanks stéphane 2016-04-13 9:22 GMT+02:00 Tilo Eckert <tilo.eckert@xxxxxxx>: > Hi Stéphane > > If I'm not mistaken, attributes->name contains only the file/directory > name. When you call your function recursively, you need to build the > full path and pass it to the recursive call. Currently, you attempt to > delete the directories from your working directory. > > Regards > Tilo > > Am 08.04.2016 um 22:58 schrieb Stéphane Lemoine: > > > > > > > > Hi, > > > > I cannot delete recursively a directory and its subdirectories,my > > function fails. > > I have a first function that delete all the files in the directory and > > its subdirectory.that first function is ok. > > my second function fails (it tries to delete the directories) > > -c++,qt,libssh- > > > > > > > > boolsshobj::supprimerepserveur(QStringdestdir) > > > > { > > > > int rc; > > > > char * p; > > > > char dat[10000]; > > > > bool res=true; > > > > p=destdir.toUtf8().data(); > > > > strcpy(dat,p); > > > > > > sftp_dir dir; > > > > sftp_attributes attributes; > > > > > > dir = sftp_opendir(m_sftp, dat); > > > > if (!dir) > > > > { > > > > > > return false; > > > > } > > > > > > while ((attributes = sftp_readdir(m_sftp, dir)) != NULL) > > > > { > > > > switch(attributes->type) > > > > { > > > > > > case SSH_FILEXFER_TYPE_DIRECTORY: > > > > { > > > > QString > rep=QString::fromUtf8(attributes->name); > > > > bool > res2=supprimerepserveur(rep); > > > > if (res2==false) > > > > res=false; > > > > > > > > break; > > > > } > > > > case SSH_FILEXFER_TYPE_REGULAR: > > > > { > > > > > > > > break; > > > > } > > > > case SSH_FILEXFER_TYPE_SYMLINK: > > > > { > > > > break; > > > > } > > > > case SSH_FILEXFER_TYPE_SPECIAL: > > > > { > > > > break; > > > > } > > > > case SSH_FILEXFER_TYPE_UNKNOWN:{ > > > > break; > > > > } > > > > } > > > > > > sftp_attributes_free(attributes); > > > > } > > > > if (!sftp_dir_eof(dir)) > > > > { > > > > sftp_closedir(dir); > > > > > > > > } > > > > rc = sftp_closedir(dir); > > > > rc = sftp_rmdir(m_sftp,dat); > > > > > > if(rc<0) > > > > res=false; > > > > return res; > > > > > > > > > > } > > > > > > do you have any idea ? > > > > stéphane. > > > > > > >
Fwd: how to delete a directory and its subdirectories with libssh ? | Stéphane Lemoine <slemoine@xxxxxxxxxxxxx> |
Re: Fwd: how to delete a directory and its subdirectories with libssh ? | Tilo Eckert <tilo.eckert@xxxxxxx> |