コード例 #1
0
ファイル: clientlet.cpp プロジェクト: Jupige/rDSN
        void copy_remote_files_impl(
            ::dsn::rpc_address remote,
            const std::string& source_dir,
            const std::vector<std::string>& files,  // empty for all
            const std::string& dest_dir,
            bool overwrite,
            dsn_task_t native_task
            )
        {
            if (files.empty())
            {
                dsn_file_copy_remote_directory(remote.c_addr(), source_dir.c_str(), dest_dir.c_str(),
                    overwrite, native_task);
            }
            else
            {
                const char** ptr = (const char**)alloca(sizeof(const char*) * (files.size() + 1));
                const char** ptr_base = ptr;
                for (auto& f : files)
                {
                    *ptr++ = f.c_str();
                }
                *ptr = nullptr;

                dsn_file_copy_remote_files(
                    remote.c_addr(), source_dir.c_str(), ptr_base,
                    dest_dir.c_str(), overwrite, native_task
                    );
            }
        }
コード例 #2
0
        task_ptr copy_remote_files(
            const dsn_address_t& remote,
            const std::string& source_dir,
            std::vector<std::string>& files,  // empty for all
            const std::string& dest_dir,
            bool overwrite,
            dsn_task_code_t callback_code,
            servicelet* owner,
            aio_handler callback,
            int hash /*= 0*/
            )
        {
            task_ptr tsk = new safe_task<aio_handler>(callback);

            if (callback != nullptr)
                tsk->add_ref(); // released in exec_aio

            dsn_task_t t = dsn_file_create_aio_task(callback_code,
                callback != nullptr ? safe_task<aio_handler>::exec_aio : nullptr,
                tsk, hash
                );

            tsk->set_task_info(t);

            if (files.empty())
            {
                dsn_file_copy_remote_directory(remote, source_dir.c_str(), dest_dir.c_str(), overwrite, t, owner ? owner->tracker() : nullptr);
            }
            else
            {
                const char** ptr = (const char**)alloca(sizeof(const char*) * (files.size() + 1));
                for (auto& f : files)
                {
                    *ptr++ = f.c_str();
                }
                *ptr = nullptr;

                dsn_file_copy_remote_files(remote, source_dir.c_str(), ptr, dest_dir.c_str(), overwrite, t, owner ? owner->tracker() : nullptr);
            }
            return tsk;
        }