//***************************************************************************************** // 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 #IFNDEF get_FileTimeToSystemTime External_Function FileTimeToSystemTime "FileTimeToSystemTime" kernel32.dll Pointer pSYSTEMTIME_ft Pointer pFILETIME Returns Integer #ENDIF #IFNDEF get_CloseHandle External_Function CloseHandle "CloseHandle" kernel32.dll Handle hFile Returns Integer #ENDIF #IFNDEF get_FindFirstFile External_Function FindFirstFile "FindFirstFileA" kernel32.dll Pointer lpFile Pointer lpFindFileData Returns Integer #ENDIF #IFNDEF get_FindClose External_Function FindClose "FindClose" kernel32.dll Handle hFile Returns Integer #ENDIF // 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 Begin Move ( (String(iMonth)) + sSeparator + (String(iDay)) + sSeparator + (String(iYear))) to dRetVal End If iFormat Eq DF_DATE_EUROPEAN Begin Move ( (String(iDay)) + sSeparator + (String(iMonth)) + sSeparator + (String(iYear))) to dRetVal End If iFormat Eq DF_DATE_MILITARY Begin Move ( (String(iYear)) + sSeparator + (String(iMonth)) + sSeparator + (String(iDay))) to dRetVal End 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<>"")) Begin Move (!3+693975) to !3 End #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 sDirSep Pointer pFile pFILETIME_ft pSYSTEMTIME_ft pFindData Integer iRet iYear iDay iMonth Handle hFile Move (SysConf(SYSCONF_DIR_SEPARATOR)) to sDirSep If (Left(sFile, 2) = ("." + sDir)) Begin Get_Current_Directory to sDir Move (Replace(("." + sDir), sFile, "")) to sFile Move (sDir + 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 sDirSep Pointer pFile pFILETIME_ft pSYSTEMTIME_ft pFindData Integer iRet iYear iDay iMonth Handle hFile String sRet Move (SysConf(SYSCONF_DIR_SEPARATOR)) to sDirSep If (Left(sFile,2) = ("." + sDirSep)) Begin Get_Current_Directory to sDir Move (Replace(("." + sDir), sFile, "")) to sFile Move (sDir + 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 String sDir sFindData sDirSep Pointer pFile pFindData Integer iRet iAttr Handle hFile Move (SysConf(SYSCONF_DIR_SEPARATOR)) to sDirSep If (Left(sFile, 2) = ("." + sDirSep)) Begin Get_Current_Directory to sDir Move (Replace(("." + sDir), sFile, "")) to sFile Move (sDir + 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 Begin Move -1 to iAttr End 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