title: how to use QFtp::list and QFtp::listInfo to check if directory exists
body: <p>I try to make ftp uploader which creates automatically subdirectories and put files in them.</p>
  
  <p>My problem is that:</p>
  
  <ul>
  <li>my uploader doesn't upload files if directory already exists.</li>
  <li>it fails on next mkdir (no error just it doesnt upload file).</li>
  </ul>
  
  <p>I know QFtp have <code>list()</code> and <code>listInfo()</code> but I don't understand how I should use in my code.</p>
  
  <p>Here is how I implemented my uploader:</p>
  
  <pre><code>ftp = new QFtp();
  ftp-&gt;setTransferMode(QFtp::Passive);
  
  ftp-&gt;connectToHost(g.ftp_host);
  ftp-&gt;login(g.ftp_user,g.ftp_password);
  ftp-&gt;list();
  ftp-&gt;cd(g.ftp_defaultdir+g.phocadir);
  
  for (int i = 0; i&lt;FulluploadFilenames-&gt;size(); i++){
      ftp-&gt;mkdir(_taj-&gt;at(i)); // should check if exists
      ftp-&gt;cd(_taj-&gt;at(i));
      ftp-&gt;mkdir(_year-&gt;at(i));
      ftp-&gt;cd(_year-&gt;at(i));
      ftp-&gt;mkdir(_month-&gt;at(i));
      ftp-&gt;cd(_month-&gt;at(i));
  
      qdata = new QFile(FulluploadFilenames-&gt;at(i),this);
      if (qdata-&gt;open(QIODevice::ReadOnly)) {
          ftp-&gt;put(qdata,uploadFilenames-&gt;at(i));
          ftp-&gt;list();
      }
  
      ftp-&gt;cd("../");
      ftp-&gt;cd("../");
      ftp-&gt;cd("../");
  }
  ftp-&gt;close();
  </code></pre>
  
  <p>This make and cd to something like this: <code>/123123123/2015/05/</code> and uploads file here.</p>
  
  <p>Could somebody please help how to check if directory exists?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Instead of checking if directories exists I forced mkdir to work in sync so it doesn't matter if fails.</p>
  
  <pre><code>void MainWindow::doUpload(){ 
  ftp = new QFtp();
  ftp-&gt;connectToHost(g.ftp_host);
  ftp-&gt;login(g.ftp_user,g.ftp_password);
  ftp-&gt;cd(g.ftp_defaultdir+g.phocadir);
  ftp-&gt;list();
  // making directories
  for (int i = 0; i&lt;FulluploadFilenames-&gt;size(); i++){
      runCommand(ftp, ftp-&gt;mkdir(_taj-&gt;at(i)));
      runCommand(ftp, ftp-&gt;mkdir(_taj-&gt;at(i)+"/"+_year-&gt;at(i)));
      runCommand(ftp, ftp-&gt;mkdir(_taj-&gt;at(i)+"/"+_year-&gt;at(i)+"/"+_month-&gt;at(i)));
  }
  // uploading files
  for (int i = 0; i&lt;FulluploadFilenames-&gt;size(); i++){
      ftp-&gt;cd(_taj-&gt;at(i)+"/"+_year-&gt;at(i)+"/"+_month-&gt;at(i));
  
      qdata = new QFile(FulluploadFilenames-&gt;at(i),this);
      if (qdata-&gt;open(QIODevice::ReadOnly)) {
          ftp-&gt;put(qdata,uploadFilenames-&gt;at(i));
      }
  
      ftp-&gt;cd("../../../");
  
      ui-&gt;progressBar-&gt;setValue(i+1);
      ui-&gt;progressBar-&gt;update();
      QCoreApplication::processEvents();
  }
  ftp-&gt;close();
  }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>void MainWindow::runCommand(QFtp *ftp, int commandId){
  QEventLoop loop;
  connect(ftp, SIGNAL(commandFinished(int, bool)), &amp;loop, SLOT(quit()));
  loop.exec();
  }
  </code></pre>