GW2DetermineFileTypeFromMemory
Hàm GW2DetermineFileTypeFromMemory xác định loại tệp của tệp có nội dung nằm trong bộ đệm được giữ trong bộ nhớ.
- C++
- C#
- Java
- Python
- JavaScript
Tóm tắt
#include "glasswall.core2.api.h"
ft_t GW2DetermineFileTypeFromFile(const char *inputFileBuffer, size_t inputLength);
Giá trị trả về
Nếu GW2DetermineFileTypeFromMemory không thể nhận diện loại tệp, hàm sẽ trả về giá trị của hằng số liệt kê ft_unknown từ kiểu liệt kê ft_t ; nếu không, hàm sẽ trả về một giá trị từ kiểu liệt kê ft_t biểu thị loại tệp. Danh sách các hằng số liệt kê nằm trong tệp tiêu đề mã nguồn C filetype.h.
Tóm tắt
/// <summary>
/// Returns a value indicating the the file type from an input file by Glasswall.
/// </summary>
/// <param name="inputFileBuffer">The input buffer containing the file to be determined</param>
/// <returns>A value indicating the determined file type</returns>s
public int DetermineFileTypeFromMemory(byte[] inputFileBuffer)
Giá trị trả về
Một giá trị cho biết loại tệp đã được xác định - Danh sách các hằng số liệt kê trong tệp tiêu đề mã nguồn C filetype.h nhất quán với giá trị được trả về cho hàm này.
Tóm tắt
import com.glasswall.core2javabridge.*;
public int GW2DetermineFileTypeFromMemory(byte[] fileBuffer) throws GlasswallException, NullPointerException
public int GW2DetermineFileTypeFromMemory(byte[] fileBuffer, int length) throws GlasswallException, NullPointerException
Lưu ý
length của fileBuffer có thể được chỉ định tùy chọn.
Giá trị trả về
Hàm GW2DetermineFileTypeFromMemory trả về một phần tử liệt kê kiểu ft_t được chuyển đổi thành int. Có thể tìm thấy danh sách các hằng số liệt kê trong tệp tiêu đề mã nguồn C filetype.h.
Một ngoại lệ NullPointerException sẽ được ném ra nếu fileBuffer là null hoặc rỗng.
Một ngoại lệ GlasswallException sẽ được ném ra nếu không thể truy xuất fileBuffer.
Tóm tắt
Xác định loại tệp của một tệp đầu vào nhất định, dưới dạng mã định danh số nguyên hoặc chuỗi.
def determine_file_type(self, input_file: Union[str, bytes, bytearray, io.BytesIO], as_string: bool = False, raise_unsupported: bool = True) -> Union[int, str]:
""" Determine the file type of a given input file, either as an integer identifier or a string.
Args:
input_file (Union[str, bytes, bytearray, io.BytesIO]): The input file to analyse. It can be provided as a file path (str), bytes, bytearray, or a BytesIO object.
as_string (bool, optional): Return file type as string, eg: "bmp" instead of: 29. Defaults to False.
raise_unsupported (bool, optional): Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.
Returns:
file_type (Union[int, str]): The file type.
"""
Giá trị trả về
Một giá trị hoặc chuỗi phần mở rộng cho biết loại tệp đã được xác định - Danh sách các hằng số liệt kê trong tệp tiêu đề mã nguồn C filetype.h nhất quán với giá trị được trả về cho hàm này.
Tóm tắt
/**
* This function determines the file type for a given file provided it is supported by Glasswall. Notice this is not related to a session.
* @param {string} path The path to the provided file.
* @returns {number} The determined file type, as enumerated in the C source header file filetype.h.
*/
GW2DetermineFileTypeFromMemory(inputFileBuffer, inputLength)
Giá trị trả về
Một giá trị cho biết loại tệp đã được xác định - Danh sách các hằng số liệt kê nằm trong tệp tiêu đề nguồn C filetype.h nhất quán với giá trị được trả về cho hàm này.