Author: jerome
Date: 2009-09-03 14:18:14 +0200 (Thu, 03 Sep 2009)
New Revision: 5323

Modified:
   
software_suite_v3/software/tool/tool-second-installer/trunk/tool-second-installer/Report.pas
   
software_suite_v3/software/tool/tool-second-installer/trunk/tool-second-installer/Unit1.pas
Log:
* Changed the way to list report directory.
* Fixed a bug zipping files on Vista ( '.' and '..'  where zipped too ).

Modified: 
software_suite_v3/software/tool/tool-second-installer/trunk/tool-second-installer/Report.pas
===================================================================
--- 
software_suite_v3/software/tool/tool-second-installer/trunk/tool-second-installer/Report.pas
        2009-09-03 12:15:33 UTC (rev 5322)
+++ 
software_suite_v3/software/tool/tool-second-installer/trunk/tool-second-installer/Report.pas
        2009-09-03 12:18:14 UTC (rev 5323)
@@ -50,6 +50,7 @@
       constructor Create(AOwner : TObject; TypeReport : Integer); overload;
       function compressReport(AApplication : TApplication) : boolean;
       function getReport() : string;
+      procedure deleteAll();
 
   end;
 
@@ -85,10 +86,6 @@
  constructor TReportMaker.Create(AOwner : TObject; TypeReport : Integer);
  begin
    inherited Create;
-   if TypeReport = Report.ERROR then
-     ReportFile   := GetEnvironmentVariable('TEMP') + '\error-logs.zip'
-   else
-     ReportFile := GetEnvironmentVariable('TEMP') + '\info-logs.zip';
 
    ReportFilesDirectory := GetEnvironmentVariable('TEMP') + '\TuxReport';
 
@@ -100,6 +97,11 @@
    if FileExists(ReportFile) then
      DeleteFile(ReportFile);
 
+   if TypeReport = Report.ERROR then
+     ReportFile   := GetEnvironmentVariable('TEMP') + '\error-logs.zip'
+   else
+     ReportFile := GetEnvironmentVariable('TEMP') + '\info-logs.zip';
+
    CreateDir(ReportFilesDirectory);
 
    ReportFiles  := TuxUtils.GetTuxDroidDataBaseDirectory() + '\logs';
@@ -110,17 +112,24 @@
 // Copy the content of a directory
 function TReportMaker.CopyDir(const fromDir, toDir: string): Boolean;
 var
-  fos: TSHFileOpStruct;
+  List : TStringList;
+  i : Integer;
 begin
-  ZeroMemory(@fos, SizeOf(fos));
-  with fos do
-  begin
-    wFunc  := FO_COPY;
-    fFlags := FOF_FILESONLY;
-    pFrom  := PChar(fromDir + #0);
-    pTo    := PChar(toDir)
+  List := TStringList.Create;
+  ListDir(ReportFiles, List);
+
+  try
+    for i := 0 to List.Count - 1 do
+      begin
+       CopyFile(PChar(List.Strings[i]), PChar(ReportFilesDirectory + '\' + 
ExtractFileName(List.Strings[i])), False);
+      end;
+    Result := true;
+  except
+    Result := false;
   end;
-  Result := (0 = ShFileOperation(fos));
+
+  List.Free;
+
 end;
 
 
@@ -205,16 +214,27 @@
         GetDir(0, s);
         if length(s) <> 3 then
           s := s + '\';
+        showmessage('found: ' + SearchRec.Name);
         List.Add(s + SearchRec.Name);
         ListDir(s + SearchRec.Name, List);
       end;
-    end else
+    end
+    else
     begin
-      GetDir(0, s);
-      if length(s) <> 3 then
-        List.add(s + '\' + SearchRec.Name)
-      else
-        List.add(s + SearchRec.Name);
+      if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
+      begin
+        GetDir(0, s);
+        if length(s) <> 3 then
+          begin
+          List.add(s + '\' + SearchRec.Name);
+          showmessage('found: ' + SearchRec.Name);
+          end
+        else
+          begin
+          List.add(s + SearchRec.Name);
+          showmessage('found: ' + SearchRec.Name);
+          end;
+      end;
     end;
     Result := FindNext(SearchRec);
     Application.ProcessMessages;
@@ -233,8 +253,8 @@
  begin
    computerDatas := ReportFilesDirectory + '\info.nfo';
    // Get the computer informations
-  msinfo := TMsinfo.create(nil);
-  msinfo.createNfo(computerDatas);
+  //msinfo := TMsinfo.create(nil);
+  //msinfo.createNfo(computerDatas);
   result := (CopyDir(ReportFiles, ReportFilesDirectory));
  end;
 
@@ -242,6 +262,7 @@
  //#### This function compress the log files.
  function TReportMaker.compressReport(AApplication : TApplication) : boolean;
  begin
+   showmessage(ReportFilesDirectory);
    Application := AApplication;
    Result := true;
 
@@ -255,10 +276,6 @@
        //And Zip all.
        if not (zipDirectory(ReportFilesDirectory, ReportFile)) then
          result := false;
-       //Deleting Temp directory.
-       sleep(500);
-       if DirectoryExists(ReportFilesDirectory) then
-         RMDir(ReportFilesDirectory);
      end
    else
      result := false;
@@ -270,7 +287,17 @@
    result := ReportFile;
  end;
 
+ {#### Delete temporary files ####}
+ procedure TReportMaker.deleteAll();
+ begin
+   if DirectoryExists(ReportFilesDirectory) then
+     RMDir(ReportFilesDirectory);
 
+   if FileExists(ReportFile) then
+     DeleteFile(ReportFile);
+ end;
+
+
 {##############################################################################
  #################   TReportSender object implementation   
#####################
  
##############################################################################}
@@ -381,7 +408,6 @@
 
   body.Add(slinebreak + 'Windows version: ' + osType);
   body.Add('User locale: ' + ComputerInfos.GetUserLanguage());
-  body.Add('Computer ran: ' + ComputerInfos.Time());
 
   IdMessage1.Body := body;
 

Modified: 
software_suite_v3/software/tool/tool-second-installer/trunk/tool-second-installer/Unit1.pas
===================================================================
--- 
software_suite_v3/software/tool/tool-second-installer/trunk/tool-second-installer/Unit1.pas
 2009-09-03 12:15:33 UTC (rev 5322)
+++ 
software_suite_v3/software/tool/tool-second-installer/trunk/tool-second-installer/Unit1.pas
 2009-09-03 12:18:14 UTC (rev 5323)
@@ -713,9 +713,10 @@
       //We can now send the report to kysoh team.
       ReportSender1.setReport(report);
       ReportSender1.send(ReportType, IdSSLIOHandlerSocket1);
-      end
+      end;
 
   finally
+    ReportMaker1.deleteAll();
     ReportMaker1.Free;
     ReportSender1.Free;
   end;


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to