GW2RegisterInputFile
Hàm GW2RegisterInputFile đăng ký đường dẫn đến tệp sẽ được xử lý trong một session.
- C++
- C#
- Java
- Python
- JavaScript
Tóm tắt
Hàm GW2RegisterInputFile đăng ký tệp sẽ được xử lý trong session session. Tên tệp là chuỗi được trỏ tới bởi inputFilePath.
#include "glasswall.core2.api.h"
int GW2RegisterInputFile(Session session, const char *inputFilePath);
Giá trị trả về
Trả về một giá trị enum GW2_RetStatus dạng số nguyên. Các số âm cho biết thất bại.
Ví dụ
#include "glasswall.core2.api.h"
HANDLE session = GW2OpenSession();
if (!session)
/* deal with error */
else
{
if (GW2RegisterInputFile(session, "filename.doc") < 0)
/* deal with error */
else
/* continue processing */
...
}
/* later */
if (GW2CloseSession(session) < 0)
/* error closing session */
Tóm tắt
public int RegisterInputFile(
int session,
string inputFilePath)
Giá trị trả về
Trả về một giá trị enum GW2_RetStatus dạng số nguyên. Các số âm cho biết thất bại.
Tóm tắt
import com.glasswall.core2javabridge.*;
public int GW2RegisterInputFile(int session, String inputFilePath) throws GlasswallException, NullPointerException
(Deprecated)
public int GW2RegisterInputFile(int session, byte[] inputFilePath) throws GlasswallException, NullPointerException
Lưu ý
Các tham số của hàm GW2RegisterInputFile đã được cập nhật để sử dụng String thay cho byte[]. Hàm gốc đã bị ngừng dùng.
Giá trị trả về
Hàm GW2RegisterInputFile trả về một giá trị liệt kê GW2_RetStatus được chuyển đổi thành int. Giá trị sẽ là số âm nếu xảy ra lỗi. 0 cho biết thành công. Tham khảo API Overview/Return types để biết chi tiết.
Một ngoại lệ NullPointerException sẽ được ném ra nếu inputFilePath là null hoặc rỗng.
Một ngoại lệ GlasswallException sẽ được ném ra nếu session không hợp lệ, nếu không thể truy xuất inputFilePath, hoặc nếu không thể chuyển đổi inputFilePath sang UTF-8.
Tóm tắt
Đăng ký một tệp đầu vào hoặc bytes cho session đã cho.
def register_input(self, session: int, input_file: Union[str, bytes, bytearray, io.BytesIO]):
""" Register an input file or bytes for the given session.
Args:
session (int): The session integer.
input_file (Union[str, bytes, bytearray, io.BytesIO]): The input file path or bytes.
Returns:
- result (glasswall.GwReturnObj): Depending on the input 'input_file':
- If input_file is a str file path:
- gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'input_file', 'status'.
- If input_file is a file in memory:
- gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.
"""
Giá trị trả về
Một đối tượng có các thuộc tính khác nhau tùy thuộc vào kiểu của input_file.
- If input_file is a str file path:
- gw_return_object (glasswall.GwReturnObj): Một thực thể GwReturnObj với các thuộc tính 'session', 'input_file', 'status'.
- If input_file is a file in memory:
- gw_return_object (glasswall.GwReturnObj): Một thực thể GwReturnObj với các thuộc tính 'session', 'buffer', 'buffer_length', 'status'.
Thuộc tính status là một giá trị enum GW2_RetStatus kiểu số nguyên. Các số âm cho biết thất bại.
Tóm tắt
Hàm này đăng ký một tệp được chỉ định làm tệp đầu vào cho một session được chỉ định
/**
*
* @param {number} session The ID of the session.
* @param {string} inputFilePath The path of the file to be registered
*/
GW2RegisterInputFile(session, inputFilePath)
Giá trị trả về
Trả về một giá trị enum GW2_RetStatus dạng số nguyên. Các số âm cho biết thất bại.