GW2DetermineFileTypeFromFile
GW2DetermineFileTypeFromFile 함수는 지정된 파일의 파일 형식을 판별합니다. 파일 형식을 식별할 수 없는 경우 열거형 타입 ft_t의 열거 상수 ft_unknown 값을 반환하고, 그렇지 않은 경우 파일 형식을 나타내는 열거형 타입 ft_t의 값을 반환합니다.
- C++
- C#
- Java
- Python
- JavaScript
#include "glasswall.core2.api.h"
ft_t GW2DetermineFileTypeFromFile(const char *path);
매개변수
path 검사하려는 파일의 절대 파일 경로입니다.
반환값
판별된 파일 형식을 나타내는 열거형 타입 ft_t입니다. 파일 형식을 판별할 수 없으면 ft_unknown가 반환됩니다.
예제
#include "glasswall.core2.api.h"
#include “filetype.h”
ft_t file_type = GW2DetermineFileTypeFromFile("c:\\dir1\\dir2\\filename");
char *type = NULL;
switch (file_type) /* categorise them */
{
case ft_doc:
case ft_docx:
case ft_ppt:
case ft_pptx:
case ft_xls:
case ft_xlsx:
type = "Microsoft Office";
break;
case ft_png:
case ft_jpg:
case ft_gif:
case ft_tiff:
type = "Image file";
break;
case ft_pdf:
type = "PDF";
break;
default:
type = "Unrecognised file type";
break;
}
개요
/// <summary>
/// Returns a value indicating the the file type from an input file by Glasswall.
/// </summary>
/// <param name="inputFilePathName">The file path to the input file</param>
/// <returns>A value indicating the determined file type </returns>
public int DetermineFileTypeFromFile(string inputFilePathName)
반환값
판별된 파일 형식을 나타내는 값 - 열거 상수 목록은 C 소스 헤더 파일 filetype.h에 있으며, 이 함수의 반환 값과 일치합니다.
개요
import com.glasswall.core2javabridge.*;
public int GW2DetermineFileTypeFromFile(String filePath) throws GlasswallException, NullPointerException
(Deprecated)
public int GW2DetermineFileTypeFromFile(byte[] BYTE) throws GlasswallException, NullPointerException
참고
The GW2DetermineFileTypeFromFile function parameters have been updated to use String in place of byte[]. The original function has been deprecated.
반환값
GW2DetermineFileTypeFromFile 함수는 Ft_t 유형의 열거자를 int로 변환하여 반환합니다. 열거 상수 목록은 C 소스 헤더 파일 filetype.h에서 확인할 수 있습니다.
NullPointerException 예외는 filePath가 null이거나 비어 있는 경우 발생합니다.
GlasswallException 예외는 filePath를 검색할 수 없는 경우 발생합니다.
개요
주어진 입력 파일의 파일 형식을 정수 식별자 또는 문자열로 판별합니다.
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.
"""
반환값
판별된 파일 형식을 나타내는 값 또는 확장자 문자열 - 열거 상수 목록은 C 소스 헤더 파일 filetype.h에 있으며, 이 함수의 반환값과 일치합니다.
개요
/**
* 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.
*/
GW2DetermineFileTypeFromFile(path)
반환값
판별된 파일 형식을 나타내는 값 - 열거 상수 목록은 C 소스 헤더 파일 filetype.h에 있으며, 이 함수의 반환 값과 일치합니다.