//***************************************************************************************** // Copyright (c) 2000 Michael Kurz // All rights reserved. // If you want to use this source in your applications conatct: // // $FileName : mFILETIME_ft.pkg // $ProjectName : Shared Methods // $Author : Michael Kurz // $Created : 01-25-2001 @ 19:00 // // Contents: // Gets the FILETIME_ft with a slightly changed Get_File_Mod_Time command which gets the // date in 4 digit format. // And also creates a TimeStamp. // // $Rev History // //***************************************************************************************** //Use mWinAPIErrorText.pkg // Function's needed for getting the FILETIME_ft. 16.05.01 Bernhard external_function FILETIMEToSYSTEMTIME "FileTimeToSystemTime" kernel32.dll Pointer pSYSTEMTIME_ft Pointer pFILETIME Returns Integer external_function CloseHandle "CloseHandle" kernel32.dll Handle hFile Returns Integer external_function FindFirstFile "FindFirstFileA" kernel32.dll Pointer lpFile Pointer lpFindFileData Returns Integer external_function FindClose "FindClose" kernel32.dll Handle hFile Returns Integer // Types needed for getting the FILETIME. 16.05.01 Bernhard TYPE SYSTEMTIME_ft Field SYSTEMTIME_ft.wYear as WORD Field SYSTEMTIME_ft.wMonth as WORD Field SYSTEMTIME_ft.wDayOfWeek as WORD Field SYSTEMTIME_ft.wDay as WORD Field SYSTEMTIME_ft.wHour as WORD Field SYSTEMTIME_ft.wMinute as WORD Field SYSTEMTIME_ft.wSecond as WORD Field SYSTEMTIME_ft.wMilliseconds as WORD END_TYPE TYPE FILETIME_ft Field FILETIME_ft.dwLowDateTime as Dword Field FIELTIME.dwHighDateTime as Dword END_TYPE TYPE WIN32_FIND_DATA_ft Field WIN32_FIND_DATA_ft.dwFileAttributes as Dword Field WIN32_FIND_DATA_ft.ftCreationTime as Char 8 Field WIN32_FIND_DATA_ft.ftLastAccessTime as Char 8 Field WIN32_FIND_DATA_ft.ftLastWriteTime as Char 8 Field WIN32_FIND_DATA_ft.nFileSizeHigh as Dword Field WIN32_FIND_DATA_ft.nFileSizeLow as Dword Field WIN32_FIND_DATA_ft.dwReserved0 as Dword Field WIN32_FIND_DATA_ft.dwReserverd1 as Dword Field WIN32_FIND_DATA_ft.cFileName as Char 260 Field WIN32_FIND_DATA_ft.cAlternateFileName as Char 14 END_TYPE // Convert 3 Integer's to a Date based on the System-Settings. 16.05.01 Bernhard Function MKConvertYearMonthDay Integer iYear Integer iMonth Integer iDay Returns Date Integer iFormat iSeparator String sSeparator Date dRetVal Get_Attribute DF_DATE_FORMAT To iFormat Get_Attribute DF_DATE_SEPARATOR To iSeparator Move (Character(iSeparator)) To sSeparator If iFormat Eq DF_DATE_USA Move ( (String(iMonth)) + sSeparator + (String(iDay)) + sSeparator + (String(iYear))) To dRetVal If iFormat Eq DF_DATE_EUROPEAN Move ( (String(iDay)) + sSeparator + (String(iMonth)) + sSeparator + (String(iYear))) To dRetVal If iFormat Eq DF_DATE_MILITARY Move ( (String(iYear)) + sSeparator + (String(iMonth)) + sSeparator + (String(iDay))) To dRetVal Function_Return dRetVal End_Function // Creates a time stamp which is a Number value which contains Date,Time in Seconds. Function MKCreateTimeStamp Global Date dDat Integer iH Integer iM Integer Is Returns Number Number nDays Number nRet Move dDat To nDays Move ((nDays*24*3600)+(iH*3600)+(iM*60)+Is) To nRet Function_Return nRet End_Function // Does a correction of the DateValue becouse the native command gets only 2 digit! #COMMAND Get_File_Mod_Time4 Get_File_Mod_Time !1 To !3 !4 !5 !6 If ((!3<50000) And (!3<>"")) Move (!3+693975) To !3 #ENDCOMMAND // Retrieves the FILETIME with the command above and creates a TimeStamp out of it. // Changed to workaround a bug in vdf's get_file_mod_time. 16.05.01 Bernhard Function MKTimeStampOfFile Global String sFile Returns Number Date dDat Number nH nM nS String sDir sFILETIME_ft sSYSTEMTIME_ft sFindData Pointer pFile pFILETIME_ft pSYSTEMTIME_ft pFindData Integer iRet iYear iDay iMonth Handle hFile If (Left(sFile,2)) Eq ".\" Begin get_current_directory To sDir Move (Replace(".\",sFile,"")) To sFile Move (sDir + "\" + sFile) To sFile End Move (sFile + (Character(0))) To sFile getaddress Of sFile To pFile Move (OemToAnsi(pFile,pFile)) To iRet zerotype WIN32_FIND_DATA_ft To sFindData getaddress Of sFindData To pFindData Move (FindFirstFile(pFile,pFindData)) To hFile If hFile Gt 0 Begin getbuff_string From sFindData at WIN32_FIND_DATA_ft.ftLastWriteTime To sFILETIME_ft zerotype SYSTEMTIME_ft To sSYSTEMTIME_ft getaddress Of sFILETIME_ft To pFILETIME_ft getaddress Of sSYSTEMTIME_ft To pSYSTEMTIME_ft Move (FiletimeToSystemtime(pFILETIME_ft,pSYSTEMTIME_ft)) To iRet If (iRet) Begin getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wYear To iYear getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wMonth To iMonth getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wDay To iDay getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wHour To nH getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wMinute To nM getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wSecond To nS Move (MKConvertYearMonthDay(Self,iYear,iMonth,iDay)) To dDat End Move (FindClose(hFile)) To iRet End Function_Return (MKCreateTimeStamp(dDat,nH,nM,nS)) End_Function // Delivers a string with the file date and time. Function MKFileTimeString Global String sFile Returns String Date dDat Number nH nM nS String sDir sFILETIME_ft sSYSTEMTIME_ft sFindData Pointer pFile pFILETIME_ft pSYSTEMTIME_ft pFindData Integer iRet iYear iDay iMonth Handle hFile String sRet If (Left(sFile,2)) Eq ".\" Begin get_current_directory To sDir Move (Replace(".\",sFile,"")) To sFile Move (sDir + "\" + sFile) To sFile End Move (sFile + (Character(0))) To sFile getaddress Of sFile To pFile Move (OemToAnsi(pFile,pFile)) To iRet zerotype WIN32_FIND_DATA_ft To sFindData getaddress Of sFindData To pFindData Move (FindFirstFile(pFile,pFindData)) To hFile If hFile Gt 0 Begin getbuff_string From sFindData at WIN32_FIND_DATA_ft.ftLastWriteTime To sFILETIME_ft zerotype SYSTEMTIME_ft To sSYSTEMTIME_ft getaddress Of sFILETIME_ft To pFILETIME_ft getaddress Of sSYSTEMTIME_ft To pSYSTEMTIME_ft Move (FiletimeToSystemtime(pFILETIME_ft,pSYSTEMTIME_ft)) To iRet If (iRet) Begin getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wYear To iYear getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wMonth To iMonth getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wDay To iDay getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wHour To nH getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wMinute To nM getbuff From sSYSTEMTIME_ft at SYSTEMTIME_ft.wSecond To nS Move (MKConvertYearMonthDay(Self,iYear,iMonth,iDay)) To dDat End Move (FindClose(hFile)) To iRet End Append sRet dDat " " (Right(Append("0",nH),2)) ":" (Right(Append("0",nM),2)) ":" (Right(Append("0",nS),2)) Function_Return sRet End_Function Define FILE_ATTRIBUTE_READONLY For |CI$00000001 Define FILE_ATTRIBUTE_ARCHIVE For |CI$00000020 // Retrieves the FILETIME_ft with the command above and creates a TimeStamp out of it. // Changed to workaround a bug in vdf's get_file_mod_time. 16.05.01 Bernhard Function MKAttribOfFile Global String sFile Returns Dword // **WvA: 18-3-2003 This is not a number according to VDF8 Date dDat Number nH nM nS String sDir sFILETIME_ft sSYSTEMTIME_ft sFindData Pointer pFile pFILETIME_ft pSYSTEMTIME_ft pFindData Integer iRet iYear iDay iMonth iAttr Handle hFile If (Left(sFile,2)) Eq ".\" Begin get_current_directory To sDir Move (Replace(".\",sFile,"")) To sFile Move (sDir + "\" + sFile) To sFile End Move (sFile + (Character(0))) To sFile getaddress Of sFile To pFile Move (OemToAnsi(pFile,pFile)) To iRet zerotype WIN32_FIND_DATA_ft To sFindData getaddress Of sFindData To pFindData Move (FindFirstFile(pFile,pFindData)) To hFile If hFile Gt 0 Begin getbuff From sFindData at WIN32_FIND_DATA_ft.dwFileAttributes To iAttr Move (FindClose(hFile)) To iRet End Else Move -1 To iAttr Function_Return iAttr End_Function // Delivers true when the given file has the Readonly attribute set to true. Function MKisFileReadOnly Global String sFile Returns Integer Function_Return (MKAttribOfFile(sFile) Iand FILE_ATTRIBUTE_READONLY) End_Function