Example #1
0
void cmd_cache(int argc, char **argv)
{
	int c;
	struct option longopts[] = {
		{"clear", no_argument, 0, 'c'},
		{"list", no_argument, 0, 'l'},
		{"touch", no_argument, 0, 't'},
		{"help", no_argument, 0, 'h'},
		{0, 0, 0, 0}
	};
	bool touch = false;

	optind = 0;
	while((c = getopt_long(argc, argv, "clt::h", longopts, 0)) != EOF) {
		switch(c) {
		  case 'c':
			ftp_cache_clear();
			return;
		  case 'l':
			ftp_cache_list_contents();
			return;
		  case 't':
			  touch = true;
			  break;
		  case 'h':
			printf(_("Control the directory cache.  Usage:\n"
					 "  cache [option] [directories]\n"
					 "Options:\n"
					 "  -c, --clear        clear whole directory cache\n"
					 "  -l, --list         list contents of cache\n"
					 "  -t, --touch        remove directories from cache\n"
					 "                     if none given, remove current"
					 " directory\n"
					 "  -h, --help         show this help\n"));
			return;
		  case '?':
			return;
		}
	}

	need_connected();
	need_loggedin();

	if(touch) {
		if(optind < argc) {
			int i;
			for(i = optind; i < argc; i++)
				ftp_cache_flush_mark(argv[i]);
		} else
			ftp_cache_flush_mark(ftp->curdir);
	} else {
		minargs(1);
		maxargs(0);
	}
}
Example #2
0
int ssh_rmdir(const char *path)
{
  char* abspath = ftp_path_absolute(path);
  stripslash(abspath);

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

  ftp_cache_flush_mark(abspath);
  ftp_cache_flush_mark_for(abspath);
  free(abspath);
  return 0;
}
Example #3
0
int ftp_rmdir(const char *path)
{
    char *p;

#ifdef HAVE_LIBSSH
    if(ftp->session)
        return ssh_rmdir(path);
#endif

    p = xstrdup(path);
    stripslash(p);
    ftp_set_tmp_verbosity(vbError);
    ftp_cmd("RMD %s", p);
    if(ftp->code == ctComplete) {
        ftp_cache_flush_mark(p);
        ftp_cache_flush_mark_for(p);
    }
    free(p);
    return ftp->code == ctComplete ? 0 : -1;
}
Example #4
0
int ssh_rmdir(const char *path)
{
	char *p;
	u_int status, id;

	p = ftp_path_absolute(path);
	stripslash(p);

	id = ftp->ssh_id++;
	ssh_send_string_request(id, SSH2_FXP_RMDIR, p, strlen(p));

	status = ssh_get_status(id);
	if(status != SSH2_FX_OK) {
		ftp_err("Couldn't remove directory: %s\n", fx2txt(status));
		free(p);
		return -1;
	}
	ftp_cache_flush_mark(p);
	ftp_cache_flush_mark_for(p);
	free(p);

	return 0;
}