class EL_WIN_FILE_INFO_C_API

(source code)

Description

Win file info c api

note
	description: "Win file info c api"

	author: "Finnian Reilly"
	copyright: "Copyright (c) 2001-2017 Finnian Reilly"
	contact: "finnian at eiffel hyphen loop dot com"

	license: "MIT license (See: en.wikipedia.org/wiki/MIT_License)"
	date: "2018-09-20 11:35:12 GMT (Thursday 20th September 2018)"
	revision: "5"

class
	EL_WIN_FILE_INFO_C_API

feature {NONE} -- C externals

	frozen default_handle: NATURAL
		external
			"C [macro %"Windows.h%"]"
		alias
			"INVALID_HANDLE_VALUE"
		end

	frozen c_open_file_read (name: POINTER): NATURAL
			-- HANDLE WINAPI CreateFile(
			-- 	_In_     LPCTSTR               lpFileName,
			-- 	_In_     DWORD                 dwDesiredAccess,
			-- 	_In_     DWORD                 dwShareMode,
			-- 	_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
			-- 	_In_     DWORD                 dwCreationDisposition,
			-- 	_In_     DWORD                 dwFlagsAndAttributes,
			-- 	_In_opt_ HANDLE                hTemplateFile
			-- );
		external
			"C inline use <Windows.h>"
		alias
			"return (EIF_NATURAL_32) CreateFile ($name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL)"
		end

	frozen c_open_file_write (name: POINTER): NATURAL
			-- HANDLE WINAPI CreateFile(
			-- 	_In_     LPCTSTR               lpFileName,
			-- 	_In_     DWORD                 dwDesiredAccess,
			-- 	_In_     DWORD                 dwShareMode,
			-- 	_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes,
			-- 	_In_     DWORD                 dwCreationDisposition,
			-- 	_In_     DWORD                 dwFlagsAndAttributes,
			-- 	_In_opt_ HANDLE                hTemplateFile
			-- );
		external
			"C inline use <Windows.h>"
		alias
			"return (EIF_NATURAL_32) CreateFile ($name, GENERIC_WRITE, NULL, NULL, OPEN_EXISTING, 0, NULL)"
		end

	frozen c_get_file_time (handle: NATURAL_32; creation_time_ptr, last_access_time_ptr, last_write_time_ptr: POINTER): BOOLEAN
			-- time pointers can be NULL if the application does not require this information.
			-- BOOL WINAPI GetFileTime (
			--		_In_      HANDLE     hFile,
			--		_Out_opt_ LPFILETIME lpCreationTime,
			--		_Out_opt_ LPFILETIME lpLastAccessTime,
			--		_Out_opt_ LPFILETIME lpLastWriteTime
			-- );
		external
			"C signature (HANDLE, LPFILETIME, LPFILETIME, LPFILETIME): EIF_BOOLEAN use <Windows.h>"
		alias
			"GetFileTime"
		end

	frozen c_close_file (handle: NATURAL): BOOLEAN
			-- BOOL WINAPI CloseHandle(_In_ HANDLE hObject);
		external
			"C (HANDLE): EIF_BOOLEAN | <Windows.h>"
		alias
			"CloseHandle"
		end

	frozen c_set_file_time (handle: NATURAL_32; creation_time_ptr, last_access_time_ptr, last_write_time_ptr: POINTER): BOOLEAN
			-- time pointers can be NULL if the application does not need to set this information.
			-- BOOL WINAPI SetFileTime(
			--		_In_           HANDLE   hFile,
			--		_In_opt_ const FILETIME *lpCreationTime,
			--		_In_opt_ const FILETIME *lpLastAccessTime,
			--		_In_opt_ const FILETIME *lpLastWriteTime
			-- )
  		external
			"C signature (HANDLE, LPFILETIME, LPFILETIME, LPFILETIME): EIF_BOOLEAN use <Windows.h>"
		alias
			"SetFileTime"
		end

feature {NONE} -- FILETIME C externals

	frozen c_sizeof_FILETIME: INTEGER_32
		external
			"C macro use <Windows.h>"
		alias
			"sizeof(FILETIME)"
		end

	frozen c_filetime_low_word (item_ptr: POINTER): NATURAL_64
		external
			"C [struct <Windows.h>] (FILETIME): EIF_NATURAL_64"
		alias
			"dwLowDateTime"
		end

	frozen c_filetime_high_word (item_ptr: POINTER): NATURAL_64
		external
			"C [struct <Windows.h>] (FILETIME): EIF_NATURAL_64"
		alias
			"dwHighDateTime"
		end

	frozen c_set_filetime_low_word (item_ptr: POINTER; value: NATURAL_32)
		external
			"C [struct <Windows.h>] (FILETIME, DWORD)"
		alias
			"dwLowDateTime"
		end

	frozen c_set_filetime_high_word (item_ptr: POINTER; value: NATURAL_32)
		external
			"C [struct <Windows.h>] (FILETIME, DWORD)"
		alias
			"dwHighDateTime"
		end

end