GW2DetermineFileTypeFromFile
GW2DetermineFileTypeFromFile फ़ंक्शन दिए गए फ़ाइल के लिए फ़ाइल प्रकार निर्धारित करता है. यदि यह फ़ाइल प्रकार की पहचान नहीं कर पाता है, तो यह enumerated type ft_t से enumeration constant ft_unknown का मान लौटाता है; अन्यथा, यह फ़ाइल प्रकार को दर्शाने वाला enumerated type ft_t से एक मान लौटाता है.
- C++
- C#
- Java
- Python
- JavaScript
#include "glasswall.core2.api.h"
ft_t GW2DetermineFileTypeFromFile(const char *path);
पैरामीटर
path उस फ़ाइल का पूर्ण फ़ाइल पथ जिसे आप जाँचना चाहते हैं.
रिटर्न
Enumerated type 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)
रिटर्न
निर्धारित फ़ाइल प्रकार दर्शाने वाला एक मान - enumeration constants की एक सूची C source header file filetype.h में है, जो इस function के लौटाए गए मान के अनुरूप है।
सारांश
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 function Ft_t प्रकार का एक enumerator लौटाता है, जिसे int में convert किया गया है। enumeration constants की एक सूची C source header file filetype.h में मिल सकती है।
A NullPointerException exception will be thrown if filePath is null or empty.
A GlasswallException exception will be thrown if filePath cannot be retrieved.
सारांश
दिए गए इनपुट फ़ाइल का फ़ाइल प्रकार निर्धारित करें, या तो एक integer identifier के रूप में या एक string के रूप में।
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.
"""
रिटर्न
निर्धारित file type को दर्शाने वाला एक value या extension string - enumeration constants की सूची C source header file filetype.h में है और इस function द्वारा लौटाए गए value के अनुरूप है.
सारांश
/**
* 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)
रिटर्न
निर्धारित फ़ाइल प्रकार दर्शाने वाला एक मान - enumeration constants की एक सूची C source header file filetype.h में है, जो इस function के लौटाए गए मान के अनुरूप है।