Exemplo n.º 1
0
static int xmp_mkdir(const char *path, mode_t mode)
{
	umask(0);
	int res;
	res = sftp_mkdir(con.sftp, path, mode);
	perror("calling mkdir");
	//res = mkdir(path, mode);
	if (res == -1)
		return -errno;

	return 0;
}
Exemplo n.º 2
0
void clSFTP::CreateDir(const wxString& dirname) throw (clException)
{
    if ( !m_sftp ) {
        throw clException("SFTP is not initialized");
    }

    int rc;
    rc = sftp_mkdir(m_sftp, dirname.mb_str(wxConvISO8859_1).data(), S_IRWXU);

    if ( rc != SSH_OK ) {
        throw clException(wxString() << _("Failed to create directory: ") << dirname << ". " << ssh_get_error(m_ssh->GetSession()), sftp_get_error(m_sftp));
    }
}
Exemplo n.º 3
0
int ssh_mkdir_verb(const char *path, verbose_t verb)
{
  char* abspath = ftp_path_absolute(path);
  stripslash(abspath);

  int rc = sftp_mkdir(ftp->sftp_session, abspath, S_IRWXU);
  if (rc != SSH_OK && sftp_get_error(ftp->sftp_session) != SSH_FX_FILE_ALREADY_EXISTS)
  {
    ftp_err(_("Couldn't create directory: %s\n"), ssh_get_error(ftp->session));
    free(abspath);
    return rc;
  }

  ftp_cache_flush_mark_for(abspath);
  free(abspath);
  return 0;
}
Exemplo n.º 4
0
int FSSftp::MkDir ( FSPath& path, int mode, int* err,  FSCInfo* info )
{
	MutexLock lock( &mutex );

	int ret = CheckSession( err, info );

	if ( ret ) { return ret; }

	if ( sftp_mkdir( sftpSession, ( char* )path.GetString( _operParam.charset ), mode ) )
	{
		if ( err ) { *err = sftp_get_error( sftpSession ); }

		return -1;
	}

	return 0;
}
Exemplo n.º 5
0
static int _sftp_mkdir(const char *uri, mode_t mode) {
  char *path = NULL;
  int rc = -1;

  if (_sftp_connect(uri) < 0) {
    return -1;
  }

  if (c_parse_uri(uri, NULL, NULL, NULL, NULL, NULL, &path) < 0) {
    return -1;
  }

  rc = sftp_mkdir(_sftp_session, path, mode);
  if (rc < 0) {
    errno = _sftp_portable_to_errno(sftp_get_error(_sftp_session));
  }

  SAFE_FREE(path);
  return rc;
}
Exemplo n.º 6
0
static void torture_sftp_mkdir(void **state) {
    struct torture_sftp *t = *state;
    char tmpdir[128] = {0};
    int rc;

    assert_false(t == NULL);

    snprintf(tmpdir, sizeof(tmpdir) - 1, "%s/mkdir_test", t->testdir);

    rc = sftp_mkdir(t->sftp, tmpdir, 0755);
    if(rc != SSH_OK)
        fprintf(stderr,"error:%s\n",ssh_get_error(t->sftp->session));
    assert_true(rc == 0);

    /* check if it really has been created */
    assert_true(torture_isdir(tmpdir));

    rc = sftp_rmdir(t->sftp, tmpdir);
    assert_true(rc == 0);

    /* check if it has been deleted */
    assert_false(torture_isdir(tmpdir));
}