GW2RegisterImportMemory
ฟังก์ชัน GW2RegisterImportMemory ลงทะเบียนตำแหน่งหน่วยความจำที่มีไฟล์ interchange ซึ่งจำเป็นสำหรับการนำเข้า ไฟล์ interchange คือไฟล์ zip ที่ได้จากกระบวนการส่งออก และตำแหน่งหน่วยความจำจะถูกจัดเตรียมโดย GW2RegisterExportMemory การใช้ฟังก์ชัน GW2RegisterImportMemory จะเปิดใช้งาน Import Process Mode สำหรับ session
- C++
- C#
- Java
- Python
- JavaScript
#include "glasswall.core2.api.h"
int GW2RegisterImportMemory(Session session, char *importFileBuffer, size_t *importLength);
พารามิเตอร์
session ID ของ session ตามที่ส่งกลับโดย GW2OpenSession.
importFileBuffer ตำแหน่งหน่วยความจำที่มีไฟล์ interchange ซึ่งจำเป็นสำหรับการนำเข้า ตำแหน่งหน่วยความจำนี้ถูกจัดเตรียมโดย GW2RegisterExportMemory และไฟล์ต้องเป็นไปตามรูปแบบไฟล์ interchange
importLength ความยาวของ importFileBuffer เป็นไบต์
ส่งกลับ
ส่งกลับจำนวนเต็มที่ระบุว่าการเรียกใช้ฟังก์ชันสำเร็จหรือไม่ ตัวเลขติดลบบ่งชี้ถึงความล้มเหลว ดูตาราง Return Types สำหรับคำอธิบายของรหัสส่งกลับ
สรุป
public int RegisterImportMemory(
int session,
byte[] importFileBuffer)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
สรุป
import com.glasswall.core2javabridge.*;
public int GW2RegisterImportMemory(int session, byte[] importBuffer) throws GlasswallException, NullPointerException
public int GW2RegisterImportMemory(int session, byte[] importBuffer, int length) throws GlasswallException, NullPointerException
หมายเหตุ
โปรดดู API Overview/Return types สำหรับ enumerator ที่ใช้ได้ของ format.
สามารถระบุ length ของ fileBuffer ได้ตามต้องการ
ส่งกลับ
ฟังก์ชัน GW2RegisterImportMemory จะส่งคืนค่า enumeration GW2_RetStatus ที่แปลงเป็น int แล้ว ค่าจะเป็นค่าติดลบหากเกิดข้อผิดพลาด 0 หมายถึงสำเร็จ โปรดดูรายละเอียดใน API Overview/Return types
จะมีการโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง หรือหากไม่สามารถดึง import buffer ได้
จะมีการโยนข้อยกเว้น NullPointerException หากบัฟเฟอร์ importBuffer เป็น null หรือว่างเปล่า
สรุป
ลงทะเบียนไฟล์ .zip ที่จะนำเข้าให้กับ session ที่กำหนด ไฟล์ที่สร้างขึ้นจะถูกสร้างระหว่างการเรียก run_session ของ session
def register_import(self, session: int, input_file: Union[str, bytes, bytearray, io.BytesIO]):
""" Registers a .zip file to be imported for the given session. The constructed file will be created during the session's run_session call.
Args:
session (int): The session integer.
input_file (Union[str, bytes, bytearray, io.BytesIO]): The input import file path or bytes.
Returns:
gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attribute 'status' indicating the result of the function call. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size.
"""
ส่งกลับ
gw_return_object (glasswall.GwReturnObj): อินสแตนซ์ GwReturnObj ที่มีแอตทริบิวต์ 'status' ระบุผลลัพธ์ของการเรียกใช้ฟังก์ชัน หาก output_file เป็น None (โหมดหน่วยความจำ) จะมี 'buffer' และ 'buffer_length' รวมอยู่ด้วย ซึ่งประกอบด้วยเนื้อหาไฟล์และขนาดไฟล์
แอตทริบิวต์ status เป็นค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงความล้มเหลว
สรุป
ฟังก์ชันนี้ลงทะเบียนตำแหน่งหน่วยความจำสำหรับนำเข้าให้กับ session ที่ระบุ
/**
* @param {number} session The ID of the session.
* @param {string} importFileBuffer A pointer to the specified memory location.
* @param {number} importLength The size of the file buffer.
*/
GW2RegisterImportMemory(session, import_File_Buffer, import_File_Buffer_Length)
ส่งกลับ
แอตทริบิวต์ status เป็นค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงความล้มเหลว