Beispiel #1
0
//Creates a request to send a file
int send_file_request(char **argv, char *filename, int op_type)
{
	int namenode_socket = connect_to_nn(argv[1], atoi(argv[2]));
	if (namenode_socket < 0)
	{
		return -1;
	}

	int result = 1;
	switch (op_type)
	{
		case 0:
			result = pull_file(namenode_socket, filename);
			break;
		case 1:
			result = push_file(namenode_socket, filename);
			break;
	}
	close(namenode_socket);
	return result;
}
Beispiel #2
0
    void pull_tree( vtrc::client::vtrc_client_sptr &client,
                    const interfaces::remote_fs    &impl,
                    const std::string              &remote_path,
                    const std::string              &local_path)
    {
        typedef vtrc::shared_ptr<interfaces::remote_fs_iterator> iterator;

        iterator i = impl.begin_iterator(remote_path);

        std::cout << "Create dirs: " << local_path << "...";
        fs::create_directories( local_path );
        std::cout << "Ok\n";

        for( ; !i->end( ); i->next( ) ) {

            bool is_dir( i->info( ).is_directory_ );

            std::string name( leaf_of(i->info( ).path_) );
            fs::path next( local_path );
            next /= name;

            if( is_dir ) {
                try {
                    pull_tree( client, impl, i->info( ).path_, next.string( ) );
                } catch( ... ) {
                    std::cout << "<iteration failed>\n";
                }
            } else if( i->info( ).is_regular_ ) {
                std::cout << "Pull file: \"" <<  i->info( ).path_ << "\""
                          << " -> " << next
                          << "\n";
                pull_file( client, impl,
                           i->info( ).path_, next.string( ),
                           44000 );
            }
        }
    }