GW2RegisterOutFile
Hàm GW2RegisterOutFile đăng ký đích đến cho tệp được quản lý do Glasswall tạo ra. Việc sử dụng hàm này kích hoạt Manage & Protect Process Mode cho phiên.
- C++
- C#
- Java
- Python
- JavaScript
Tóm tắt
Đối với phiên session, hàm GW2RegisterOutFile đăng ký tệp có tên là chuỗi được outputFileBuffer trỏ tới làm tệp đích cho tệp được quản lý do Glasswall tạo ra. Tên cơ sở của đường dẫn phải khác với tên cơ sở đã được đăng ký bằng hàm GW2RegisterInputFile. Việc sử dụng hàm này kích hoạt Manage & Protect Process Mode cho phiên.
#include "glasswall.core2.api.h"
int GW2RegisterOutFile(Session session, const char *outputFilePath);
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 (GW2RegisterOutFile(session, "managed_file.docx") < 0)
/* deal with error */
else
/* continue processing */
...
}
/* later */
if (GW2CloseSession(session) < 0)
/* error closing session */
Tóm tắt
public int RegisterOutFile(
int session,
string outputFilePath)
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 GW2RegisterOutFile(int session, String outputFilePath) throws GlasswallException, NullPointerException
(Deprecated)
public int GW2RegisterOutFile(int session, byte[] outputFilePath) throws GlasswallException, NullPointerException
Lưu ý
Các tham số của hàm GW2RegisterOutFile đã được cập nhật để sử dụng String thay cho byte[]. Hàm gốc đã bị deprecated.
Giá trị trả về
Hàm GW2RegisterOutFile 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 outputFilePath 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 outputFilePath, hoặc nếu không thể chuyển đổi outputFilePath sang UTF-8.
Tóm tắt
Đăng ký một tệp đầu ra cho phiên đã cho. Nếu output_file là None thì tệp sẽ được trả về dưới dạng các thuộc tính 'buffer' và 'buffer_length'.
def register_output(self, session, output_file: Optional[str] = None):
""" Register an output file for the given session. If output_file is None the file will be returned as 'buffer' and 'buffer_length' attributes.
Args:
session (int): The session integer.
output_file (Optional[str]): If specified, during run session the file will be written to output_file, otherwise the file will be written to the glasswall.GwReturnObj 'buffer' and 'buffer_length' attributes.
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.
"""
Giá trị trả về
gw_return_object (glasswall.GwReturnObj): Một thể hiện GwReturnObj với thuộc tính 'status' cho biết kết quả của lệnh gọi hàm. Nếu output_file là None (chế độ bộ nhớ), 'buffer' và 'buffer_length' sẽ được bao gồm, chứa nội dung tệp và kích thước tệp.
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 đích cho tệp được quản lý do Glasswall tạo ra.
/**
* @param {number} session The ID of the session.
* @param {string} outputFilePath The specified output path. Must be different to the specified input file path.
*/
GW2RegisterOutFile(
session,
outputFilePath)
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.