[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: how to delete a directory and its subdirectories with libssh ?


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-



bool sshobj::supprimerepserveur(QString destdir)

{

    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.

Archive administrator: postmaster@lists.cynapses.org