|
| 1 | +//+------------------------------------------------------------------+ |
| 2 | +//| fileapi.mqh | |
| 3 | +//| Copyright 2018, MetaQuotes Software Corp. | |
| 4 | +//| https://www.mql5.com | |
| 5 | +//+------------------------------------------------------------------+ |
| 6 | +#property copyright "Copyright 2018, MetaQuotes Software Corp." |
| 7 | +#property link "https://www.mql5.com" |
| 8 | +//--- |
| 9 | +#include <WinAPI\windef.mqh> |
| 10 | +//+------------------------------------------------------------------+ |
| 11 | +//| | |
| 12 | +//+------------------------------------------------------------------+ |
| 13 | +//--- |
| 14 | +enum STREAM_INFO_LEVELS |
| 15 | + { |
| 16 | + FindStreamInfoStandard, |
| 17 | + FindStreamInfoMaxInfoLevel |
| 18 | + }; |
| 19 | +//+------------------------------------------------------------------+ |
| 20 | +//| | |
| 21 | +//+------------------------------------------------------------------+ |
| 22 | +//--- |
| 23 | +struct BY_HANDLE_FILE_INFORMATION |
| 24 | + { |
| 25 | + uint dwFileAttributes; |
| 26 | + FILETIME ftCreationTime; |
| 27 | + FILETIME ftLastAccessTime; |
| 28 | + FILETIME ftLastWriteTime; |
| 29 | + uint dwVolumeSerialNumber; |
| 30 | + uint nFileSizeHigh; |
| 31 | + uint nFileSizeLow; |
| 32 | + uint nNumberOfLinks; |
| 33 | + uint nFileIndexHigh; |
| 34 | + uint nFileIndexLow; |
| 35 | + }; |
| 36 | +//--- |
| 37 | +struct CREATEFILE2_EXTENDED_PARAMETERS |
| 38 | + { |
| 39 | + uint dwSize; |
| 40 | + uint dwFileAttributes; |
| 41 | + uint dwFileFlags; |
| 42 | + uint dwSecurityQosFlags; |
| 43 | + PVOID lpSecurityAttributes; |
| 44 | + HANDLE hTemplateFile; |
| 45 | + }; |
| 46 | +//--- |
| 47 | +struct FILE_ATTRIBUTE_DATA |
| 48 | + { |
| 49 | + uint dwFileAttributes; |
| 50 | + FILETIME ftCreationTime; |
| 51 | + FILETIME ftLastAccessTime; |
| 52 | + FILETIME ftLastWriteTime; |
| 53 | + uint nFileSizeHigh; |
| 54 | + uint nFileSizeLow; |
| 55 | + }; |
| 56 | +//--- |
| 57 | +struct FIND_STREAM_DATA |
| 58 | + { |
| 59 | + long StreamSize; |
| 60 | + short cStreamName[MAX_PATH+36]; |
| 61 | + }; |
| 62 | +//--- |
| 63 | +struct FIND_DATAW |
| 64 | + { |
| 65 | + uint dwFileAttributes; |
| 66 | + FILETIME ftCreationTime; |
| 67 | + FILETIME ftLastAccessTime; |
| 68 | + FILETIME ftLastWriteTime; |
| 69 | + uint nFileSizeHigh; |
| 70 | + uint nFileSizeLow; |
| 71 | + uint dwReserved0; |
| 72 | + uint dwReserved1; |
| 73 | + short cFileName[MAX_PATH]; |
| 74 | + short cAlternateFileName[14]; |
| 75 | + }; |
| 76 | +//+------------------------------------------------------------------+ |
| 77 | +//| | |
| 78 | +//+------------------------------------------------------------------+ |
| 79 | +#import "kernel32.dll" |
| 80 | +int AreFileApisANSI(void); |
| 81 | +int CompareFileTime(FILETIME &file_time1,FILETIME &file_time2); |
| 82 | +int CreateDirectoryW(const string path_name,PVOID security_attributes); |
| 83 | +HANDLE CreateFile2(const string file_name,uint desired_access,uint share_mode,uint creation_disposition,CREATEFILE2_EXTENDED_PARAMETERS &create_ex_params); |
| 84 | +HANDLE CreateFileW(const string file_name,uint desired_access,uint share_mode,PVOID security_attributes,uint creation_disposition,uint flags_and_attributes,HANDLE template_file); |
| 85 | +int DefineDosDeviceW(uint flags,const string device_name,const string target_path); |
| 86 | +int DeleteFileW(const string file_name); |
| 87 | +int DeleteVolumeMountPointW(const string volume_mount_point); |
| 88 | +int FileTimeToLocalFileTime(FILETIME &file_time,FILETIME &local_file_time); |
| 89 | +int FindClose(HANDLE find_file); |
| 90 | +int FindCloseChangeNotification(HANDLE change_handle); |
| 91 | +HANDLE FindFirstChangeNotificationW(const string path_name,int watch_subtree,uint notify_filter); |
| 92 | +HANDLE FindFirstFileExW(const string file_name,FINDEX_INFO_LEVELS info_level_id,FIND_DATAW &find_file_data,FINDEX_SEARCH_OPS search_op,PVOID search_filter,uint additional_flags); |
| 93 | +HANDLE FindFirstFileNameW(const string file_name,uint flags,uint &StringLength,ushort &LinkName[]); |
| 94 | +HANDLE FindFirstFileW(const string file_name,FIND_DATAW &find_file_data); |
| 95 | +HANDLE FindFirstStreamW(const string file_name,STREAM_INFO_LEVELS InfoLevel,FIND_STREAM_DATA &find_stream_data,uint flags); |
| 96 | +HANDLE FindFirstVolumeW(ushort &volume_name[],uint &buffer_length); |
| 97 | +int FindNextChangeNotification(HANDLE change_handle); |
| 98 | +int FindNextFileNameW(HANDLE find_stream,uint &StringLength,ushort &LinkName[]); |
| 99 | +int FindNextFileW(HANDLE find_file,FIND_DATAW &find_file_data); |
| 100 | +int FindNextStreamW(HANDLE find_stream,FIND_STREAM_DATA &find_stream_data); |
| 101 | +int FindNextVolumeW(HANDLE find_volume,ushort &volume_name[],uint &buffer_length); |
| 102 | +int FindVolumeClose(HANDLE find_volume); |
| 103 | +int FlushFileBuffers(HANDLE file); |
| 104 | +uint GetCompressedFileSizeW(const string file_name,uint &file_size_high); |
| 105 | +int GetDiskFreeSpaceExW(const string directory_name,ulong &free_bytes_available_to_caller,ulong &total_number_of_bytes,ulong &total_number_of_free_bytes); |
| 106 | +int GetDiskFreeSpaceW(const string root_path_name,uint §ors_per_cluster,uint &bytes_per_sector,uint &number_of_free_clusters,uint &total_number_of_clusters); |
| 107 | +uint GetDriveTypeW(const string root_path_name); |
| 108 | +int GetFileAttributesExW(const string file_name,GET_FILEEX_INFO_LEVELS info_level_id,FILE_ATTRIBUTE_DATA &file_information); |
| 109 | +uint GetFileAttributesW(const string file_name); |
| 110 | +int GetFileInformationByHandle(HANDLE file,BY_HANDLE_FILE_INFORMATION &file_information); |
| 111 | +uint GetFileSize(HANDLE file,uint &file_size_high); |
| 112 | +int GetFileSizeEx(HANDLE file,long &file_size); |
| 113 | +int GetFileTime(HANDLE file,FILETIME &creation_time,FILETIME &last_access_time,FILETIME &last_write_time); |
| 114 | +uint GetFileType(HANDLE file); |
| 115 | +uint GetFinalPathNameByHandleW(HANDLE file,ushort &file_path[],uint file_path,uint flags); |
| 116 | +uint GetFullPathNameW(const string file_name,uint buffer_length,ushort &buffer[],ushort &file_part[]); |
| 117 | +uint GetLogicalDrives(void); |
| 118 | +uint GetLogicalDriveStringsW(uint buffer_length,ushort &buffer[]); |
| 119 | +uint GetLongPathNameW(const string short_path,string &long_path,uint buffer); |
| 120 | +uint GetShortPathNameW(const string long_path,string &short_path,uint buffer); |
| 121 | +uint GetTempFileNameW(const string path_name,const string prefix_string,uint unique,ushort &temp_file_name[]); |
| 122 | +uint GetTempPathW(uint buffer_length,ushort &buffer[]); |
| 123 | +int GetVolumeInformationByHandleW(HANDLE file,ushort &volume_name_buffer[],uint volume_name_size,uint &volume_serial_number,uint &maximum_component_length,uint &file_system_flags,ushort &file_system_name_buffer[],uint file_system_name_size); |
| 124 | +int GetVolumeInformationW(const string root_path_name,ushort &volume_name_buffer[],uint volume_name_size,uint &volume_serial_number,uint &maximum_component_length,uint &file_system_flags,ushort &file_system_name_buffer[],uint file_system_name_size); |
| 125 | +int GetVolumeNameForVolumeMountPointW(const string volume_mount_point,string volume_name,uint buffer_length); |
| 126 | +int GetVolumePathNamesForVolumeNameW(const string volume_name,string volume_path_names,uint buffer_length,uint &return_length); |
| 127 | +int GetVolumePathNameW(const string file_name,ushort &volume_path_name[],uint buffer_length); |
| 128 | +int LocalFileTimeToFileTime(FILETIME &local_file_time,FILETIME &file_time); |
| 129 | +int LockFile(HANDLE file,uint file_offset_low,uint file_offset_high,uint number_of_bytes_to_lock_low,uint number_of_bytes_to_lock_high); |
| 130 | +int LockFileEx(HANDLE file,uint flags,uint reserved,uint number_of_bytes_to_lock_low,uint number_of_bytes_to_lock_high,OVERLAPPED &overlapped); |
| 131 | +uint QueryDosDeviceW(const string device_name,ushort &target_path[],uint max); |
| 132 | +int ReadFile(HANDLE file,ushort &buffer[],uint number_of_bytes_to_read,uint &number_of_bytes_read,OVERLAPPED &overlapped); |
| 133 | +int ReadFile(HANDLE file,ushort &buffer[],uint number_of_bytes_to_read,uint &number_of_bytes_read,PVOID overlapped); |
| 134 | +int ReadFileScatter(HANDLE file,FILE_SEGMENT_ELEMENT &segment_array[],uint number_of_bytes_to_read,uint &reserved,OVERLAPPED &overlapped); |
| 135 | +int ReadFileScatter(HANDLE file,FILE_SEGMENT_ELEMENT &segment_array[],uint number_of_bytes_to_read,uint &reserved,PVOID overlapped); |
| 136 | +int RemoveDirectoryW(const string path_name); |
| 137 | +int SetEndOfFile(HANDLE file); |
| 138 | +void SetFileApisToANSI(void); |
| 139 | +void SetFileApisToOEM(void); |
| 140 | +int SetFileAttributesW(const string file_name,uint file_attributes); |
| 141 | +int SetFileInformationByHandle(HANDLE file,FILE_INFO_BY_HANDLE_CLASS FileInformationClass,FILE_INFO &file_information,uint buffer_size); |
| 142 | +int SetFileIoOverlappedRange(HANDLE FileHandle,uchar &OverlappedRangeStart,ulong Length); |
| 143 | +uint SetFilePointer(HANDLE file,long distance_to_move,long &distance_to_move_high,uint move_method); |
| 144 | +int SetFilePointerEx(HANDLE file,long distance_to_move,long &new_file_pointer,uint move_method); |
| 145 | +int SetFileTime(HANDLE file,FILETIME &creation_time,FILETIME &last_access_time,FILETIME &last_write_time); |
| 146 | +int SetFileValidData(HANDLE file,long ValidDataLength); |
| 147 | +int UnlockFile(HANDLE file,uint file_offset_low,uint file_offset_high,uint number_of_bytes_to_unlock_low,uint number_of_bytes_to_unlock_high); |
| 148 | +int UnlockFileEx(HANDLE file,uint reserved,uint number_of_bytes_to_unlock_low,uint number_of_bytes_to_unlock_high,OVERLAPPED &overlapped); |
| 149 | +int WriteFile(HANDLE file,const ushort &buffer[],uint number_of_bytes_to_write,uint &number_of_bytes_written,OVERLAPPED &overlapped); |
| 150 | +int WriteFile(HANDLE file,const ushort &buffer[],uint number_of_bytes_to_write,uint &number_of_bytes_written,PVOID overlapped); |
| 151 | +int WriteFileGather(HANDLE file,FILE_SEGMENT_ELEMENT &segment_array[],uint number_of_bytes_to_write,uint &reserved,OVERLAPPED &overlapped); |
| 152 | +int WriteFileGather(HANDLE file,FILE_SEGMENT_ELEMENT &segment_array[],uint number_of_bytes_to_write,uint &reserved,PVOID overlapped); |
| 153 | +#import |
| 154 | +//+------------------------------------------------------------------+ |
0 commit comments