示例#1
0
文件: list.c 项目: mabm/Bertomzilla
void			ftp_list(t_client *client, char *str)
{
  FILE			*fd;
  int			client_fd;
  struct sockaddr_in	cliaddr;
  socklen_t		clilen;
  char			*arg;
  char			buff[4096];

  arg = get_cmd(str, 4);
  if (!is_passive(client))
    return;
  clilen = sizeof(cliaddr);
  if (!is_authorized_path(client, arg))
    return (bad_path(client));
  client_fd = accept(client->pasv_sck,
		     (struct sockaddr *)&cliaddr, &clilen);
  write(client->fd, "150 Accepted data connection\r\n",
	strlen("150 Accepted data connection\r\n"));
  sprintf(buff, "ls -la %s > /tmp/.result", arg);
  system(buff);
  if (!(fd = fopen("/tmp/.result", "r")))
    return (cond_is_ok(client, client_fd));
   end_list(client, fd, client_fd);
}
		/*
			Test for path checking
		*/
		void checkPaths() {
			isTrue(::core::Path::exists("."));
			isTrue(::core::Path::exists("tests"));
			isTrue(::core::Path::exists("tests/filesystem_tests.hpp"));
			isFalse(::core::Path::exists("aaaaaaaaaaaaaaaaaaaaaaaa"));

			::core::Path path("tests");
			isTrue(path.exists());
			::core::Path bad_path("aaaaaaaaaaaaaaaaaa");
			isFalse(bad_path.exists());
		}