//**************************************************************************************** //* FindFile.Pkg //* //* //* Inhalt: //* Wenn man mit den Direct_Input "DIR:..." Command Verzeichnisse nach Dateien durch- //* sucht, gibt es Probleme mit den Umlauten, die nicht nur auf den Ansi Zeichensatz //* zurueckzufuehren sind! //* Mit der Windows API hauts aber gut hin! //* //* //* Michael Kurz 05.08.2000 //**************************************************************************************** //**************************************************************************************** //* Class: cDirList //* //* Description: //* Reads Files from a directory and displays them. The visualisation object is //* based on a grid and displays the file with icon and filename. //* //* Usage: //* Object oDirList is a cDirList //* send AddFileListSrc "C:\Eigene Dateien\*.INI" // Reads this files //* send AddFileListSrc "C:\Eigene Dateien\*.BMP" // ... //* ... //* //* set Location to ... //* set Size to ... //* //* set piColumns to ... // number of columns (std.: 1) //* send SingleLineState True //* set piNoTextState to True // Display no text! //* //* // Put your Action here.. //* Procedure onFileChosen string sFile date dDat string sTime //* Forward send onFileChosen string sFile date dDat string sTime // Standard Action: Open/ Save as behavier! //* End_Procedure //* End_Object //* //* //**************************************************************************************** // **WvA: 18-03-03 A minor change in the names has been introduced to prevent compilererrors // under VDF8 and up. This includes WinFindFirstFile, WinFindNextFile and WinFindClose // These functions are changed into: Win32FindFirstFile, Win32FindNextFile and Win32FindClose Use tWinStructs.pkg Define QSO_Cancel For 0 Define QSO_Save For 1 Define QSO_Open For 2 #IF (!@ < 200) External_Function ffFindFirstFile "FindFirstFileA" Kernel32.DLL String sFile Pointer pFindData Returns Handle External_Function ffFindNextFile "FindNextFileA" Kernel32.DLL Handle hFind Pointer pFindData Returns Handle #ELSE External_Function ffFindFirstFile "FindFirstFileW" Kernel32.DLL WString sFile Pointer pFindData Returns Handle External_Function ffFindNextFile "FindNextFileW" Kernel32.DLL Handle hFind Pointer pFindData Returns Handle #ENDIF External_function ffFindClose "FindClose" Kernel32.DLL Handle hFind Returns Integer //Use FileInfo.pkg Use mFiles.pkg Use VdfBase.pkg // VDF12+ //Class cSystemTime Is a Message // Procedure Construct_Object // Forward Send Construct_Object // Property Integer wYear PUBLIC 0 // Property Integer wMonth PUBLIC 0 // Property Integer wDayOfWeek PUBLIC 0 // Property Integer wDay PUBLIC 0 // Property Integer wHour PUBLIC 0 // Property Integer wMinute PUBLIC 0 // Property Integer wSecond PUBLIC 0 // Property Integer wMilliseconds PUBLIC 0 // End_Procedure // // Procedure Fill String sBuff // Local Integer iWert // GetBuff From sBuff at SYSTEMTIME.wYear To iWert // Set wYear To iWert // GetBuff From sBuff at SYSTEMTIME.wMonth To iWert // Set wMonth To iWert // GetBuff From sBuff at SYSTEMTIME.wDayOfWeek To iWert // Set wDayOfWeek To iWert // GetBuff From sBuff at SYSTEMTIME.wDay To iWert // Set wDay To iWert // GetBuff From sBuff at SYSTEMTIME.wHour To iWert // Set wHour To iWert // GetBuff From sBuff at SYSTEMTIME.wMinute To iWert // Set wMinute To iWert // GetBuff From sBuff at SYSTEMTIME.wSecond To iWert // Set wSecond To iWert // GetBuff From sBuff at SYSTEMTIME.wMilliseconds To iWert // Set wMilliseconds To iWert // End_Procedure // // Procedure FillFileTime String sTime // Move (FileTimeToSystemTime(sTime)) To sTime // Send Fill sTime // End_Procedure // // Transfers Data from one to another Object! // Procedure TransferData Integer iID // Set wYear Of iID To (wYear(Self)) // Set wMonth Of iID To (wMonth(Self)) // Set wDayOfWeek Of iID To (wDayOfWeek(Self)) // Set wDay Of iID To (wDay(Self)) // Set wHour Of iID To (wHour(Self)) // Set wMinute Of iID To (wMinute(Self)) // Set wSecond Of iID To (wSecond(Self)) // Set wMilliSeconds Of iID To (wMilliSeconds(Self)) // End_Procedure // // Function GetDatum Returns Date // Local String sRet // Append sRet (wDay(Self)) "." (wMonth(Self)) "." (wYear(Self)) // Function_Return sRet // End_Function // Function GetZeit Returns String // Local String sRet // Append sRet (wHour(Self)) ":" (wMinute(Self)) ":" (wSecond(Self)) // Function_Return sRet // End_Function //End_Class Class cFileFindData Is a Message Procedure Construct_Object Property Handle phFileFindHandle -1 Property Integer piFileAttributes 0 Property Integer piFileSizeHigh 0 Property Integer piFileSizeLow 0 // ... Property String psFileName "" Property String psAlternateFileName "" Property String psSearchPath "" // Object oCreationTime Is a cSystemTime // End_Object // Object oLastAccessTime Is a cSystemTime // End_Object // Object oLastWriteTime Is a cSystemTime // End_Object End_Procedure Procedure Fill tWIN32_FIND_DATA Win32FindData String sFileName String sAltFileName Integer iTmp // GetBuff_String From sData at WIN32_FIND_DATA.ftCreationTime To sTmp // Daten Eintragen.... // Send FillFileTime To (oCreationTime(Self)) sTmp // GetBuff_String From sData at WIN32_FIND_DATA.ftLastAccessTime To sTmp // Send FillFileTime To (oLastAccessTime(Self)) sTmp // GetBuff_String From sData at WIN32_FIND_DATA.ftLastWriteTime To sTmp // Send FillFileTime To (oLastWriteTime(Self)) sTmp Move Win32FindData.nFileSizeHigh To iTmp Set piFileSizeHigh To iTmp Move Win32FindData.nFileSizeLow To iTmp Set piFileSizeLow To iTmp #IF (!@ < 200) Move (UCharArrayToString(Win32FindData.cFileName)) To sFileName Move (UCharArrayToString(Win32FindData.cAlternateFileName)) To sAltFileName Set psFileName To (ToOem(CString(sFileName))) Set psAlternateFileName To (ToOem(CString(sAltFileName))) #ELSE Move (PointerToWString(AddressOf(Win32FindData.cFileName))) To sFileName Move (PointerToWString(AddressOf(Win32FindData.cAlternateFileName))) To sAltFileName Set psFileName To (CString(sFileName)) Set psAlternateFileName To (CString(sAltFileName)) #ENDIF End_Procedure Function GetSizeStr Returns String Integer Is Get piFileSizeLow To Is If Is Ge 10000 Begin Function_Return (Append(Is/1000," K")) End Else Begin Function_Return (Append(Is, " Byte")) End End_Function // Returns PAth and File... Function FullFileName Returns String String sRet Append sRet (psSearchPath(Self)) "\" (psFileName(Self)) Function_Return sRet End_Function // Creates a FileInfostring containing FileName, FileSize and LastWriteTime! Function FileInfoStr Returns String String sRet Append sRet (psFileName(Self)) " (" (GetSizeStr(Self)) ")" Function_Return sRet End_Function // Is it a Directory? Not exactly a full proof test Function isDir Returns Integer String sFile Get psFileName To sFile If (Trim(sFile)) Eq ".." Function_Return 1 If (Trim(sFile)) Eq "." Function_Return 1 Function_Return 0 End_Function End_Class Function Win32FindFirstFile Global String sFile Returns Integer Integer iRet iOID tWIN32_FIND_DATA Win32FindData #IF (!@ < 200) Move (ToAnsi(sFile)) To sFile #ENDIF Append sFile (Character(0)) Move 0 To Win32FindData.nFileSizeLow Move (ffFindFirstFile(sFile,AddressOf(Win32FindData))) To iRet If iRet Gt 0 Begin Object oFileFindData Is a cFileFindData // Object erzeugen... Move Self To iOID End_Object Set phFileFindHandle Of iOID To iRet Set psSearchPath Of iOID To (PathFromPath(sFile)) Send Fill To iOID Win32FindData End Function_Return iOID End_Function Function Win32FindNextFile GLOBAL Integer iOID Returns Integer Integer iRet Handle hH tWIN32_FIND_DATA Win32FindData Move 0 To Win32FindData.nFileSizeLow If Not iOID Function_Return -1 Get phFileFindHandle Of iOID To hH Move (ffFindNextFile(hH,AddressOf(Win32FindData))) To iRet Send Fill To iOID Win32FindData // Must also call when empty Function_Return iRet End_Function Function Win32FindClose Global Integer iOID Returns Integer Handle hH Integer iRet If Not iOID Function_Return -1 Get phFileFindHandle Of iOID To hH // FindHandle holen If hH Move (ffFindClose(hH)) To iRet // freigeben wenn gueltig Send Destroy_Object To iOID // Object freigeben! Function_Return iRet // Freigabe OK? End_Function // // Returns the correct case sensitivity for a filename. If you test for the existence // of a file using Get_File_Path then the filename itself will keep the case you give // it. Opening files that way and editing them, can change the case and some // code source tools don't like that. // Pre: The filename must exist // Function FileNameOnDisk String sFileName Returns String Integer hoId iRet String sRealName Move (Win32FindFirstFile(sFileName)) To hoId If hoId Begin Get FullFileName Of hoID To sRealName // Move (Win32FindNextFile(hoId)) To iRet // If iRet send iMsg hoId Move (Win32FindClose(hoId)) To iRet End Function_Return sRealName End_Function // FileNameOnDisk