//***************************************************************************************** // 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 GlobalFunctionsProcedures.pkg Use tWinStructs.pkg //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 #IF (!@ < 200) External_function FindFirstFile "FindFirstFileA" kernel32.dll String sFile Pointer lpFindFileData Returns Handle #ELSE External_function FindFirstFile "FindFirstFileW" kernel32.dll WString wFile Pointer lpFindFileData Returns Handle #ENDIF external_function FindClose "FindClose" kernel32.dll Handle hFile Returns Integer // 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 Integer iRet iYear iDay iMonth Handle hFile tWinFileTime ftLastWriteTime tWinSystemTime WinSystemTime #IF (!@ < 200) tWIN32_FIND_DATA FindData #ELSE tWin32FindDataW FindData #ENDIF 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 #IF (!@ < 200) Move (ToAnsi(sFile)) To sFile #ENDIF Move 0 To FindData.nFileSizeLow Move (FindFirstFile(sFile,AddressOf(FindData))) To hFile If hFile Gt 0 Begin Move FindData.ftLastWriteTime To ftLastWriteTime Move 0 To WinSystemTime.wSecond Move (FiletimeToSystemtime(AddressOf(ftLastWriteTime),AddressOf(WinSystemTime))) To iRet If (iRet) Begin Move WinSystemTime.wYear To iYear Move WinSystemTime.wMonth To iMonth Move WinSystemTime.wDay To iDay Move WinSystemTime.wHour To nH Move WinSystemTime.wMinute To nM Move WinSystemTime.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 Integer iRet iYear iDay iMonth Handle hFile String sRet tWinFileTime ftLastWriteTime tWinSystemTime WinSystemTime #IF (!@ < 200) tWIN32_FIND_DATA FindData #ELSE tWin32FindDataW FindData #ENDIF 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 #IF (!@ < 200) Move (ToAnsi(sFile)) To sFile #ENDIF Move 0 To FindData.nFileSizeLow Move (FindFirstFile(sFile,AddressOf(FindData))) To hFile If hFile Gt 0 Begin MOve FindData.ftLastWriteTime To ftLastWriteTime Move 0 To WinSystemTime.wSecond Move (FiletimeToSystemtime(AddressOf(ftLastWriteTime),AddressOf(WinSystemTime))) To iRet If (iRet) Begin Move WinSystemTime.wYear To iYear Move WinSystemTime.wMonth To iMonth Move WinSystemTime.wDay To iDay Move WinSystemTime.wHour To nH Move WinSystemTime.wMinute To nM Move WinSystemTime.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 Attribute with the command above // 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 Integer iRet iYear iDay iMonth iAttr Handle hFile #IF (!@ < 200) tWIN32_FIND_DATA FindData #ELSE tWin32FindDataW FindData #ENDIF 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 #IF (!@ < 200) Move (ToAnsi(sFile)) To sFile #ENDIF Move 0 To FindData.nFileSizeLow Move (FindFirstFile(sFile,AddressOf(FindData))) To hFile If hFile Gt 0 Begin Move FindData.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