Revision 7902 branches/v10/install/launcher/izpack-launcher-1.3/src/launcher.cpp

View differences:

launcher.cpp
939 939
	target = parseString(target);
940 940
	if (wxFileExists(target)){
941 941
		continue;
942
	} else {
943
	    if (wxDirExists(target)) {
944
	        fileName = wxFileName(target);
945
		wxFileName tempFileName(source);
946
	        fileName.SetFullName(tempFileName.GetFullName());
947
		if (fileName.FileExists()) {
948
			continue;
949
		}
950
	    }
951
				
942 952
	}
943 953
	if (!wxFileExists(source)){
944 954
		error(source.Format(_("Error copying the file number %i:\n source file '%s' does not exists."),i,source.c_str()));
......
948 958
	fileName = wxFileName(source);
949 959
	msg = msg.Format(_("copying %s..."), fileName.GetFullName().c_str());
950 960
	//echo(msg);
961
	//echo(msg.Format("%s --> %s",source.c_str(),target.c_str()));
951 962
	if (!copyFile(source,target, msg)){
952 963
		error(source.Format(_("Error copying the file number %i:\n '%s' --> '%s'."),i,source.c_str(),target.c_str()));
953 964
		return false;
......
970 981
  }
971 982
  
972 983
  showStatusMsg(msg);
973
  //wxFile fileSource(source);
974
  //wxFileInputStream in_stream(fileSource);
975
  wxFileInputStream in_stream(source);
976 984

  
977
  //in_stream = url.GetInputStream();
978
  //echo("in_stream open");
979
  if (!in_stream.IsOk()) {
980
     //echo("in_stream.IsOk == false");
981
     return false;
982
  }
983
  //echo("in_stream.IsOk == true");
984
  //echo("target =" + target);
985 985
  wxFileName targetFileName(target);
986 986
  
987 987
  
......
1014 1014
  }
1015 1015

  
1016 1016
  wxString finalTarget;
1017
  if (targetFileName.IsDir()) { 
1017
  if (targetFileName.IsDir() || targetFileName.DirExists()) { 
1018
      //echo("targetFileName.IsDir -> true  " + targetFileName.GetFullPath());
1018 1019
      wxFileName sourceFileName(source);
1019 1020
      targetFileName.SetFullName(sourceFileName.GetFullName());
1020 1021
      finalTarget = targetFileName.GetFullPath();
1021 1022
  } else {
1023
      //echo("targetFileName.IsDir -> false  " + targetFileName.GetFullPath());
1022 1024
      finalTarget = target;
1023 1025
  }
1024
  
1025
  
1026
  wxFileOutputStream out_stream  = wxFileOutputStream(finalTarget);
1027
  //echo("out_stream open");
1028
  
1029
  //in_stream->Read(out_stream);
1030
  size_t nbytes = 10240;
1031
  char buffer[nbytes];
1032
  
1033
  
1034
  //while (!in_stream->Eof()) {
1035
  while (!in_stream.Eof()) {
1036
      in_stream.Read(&buffer,nbytes);  
1037
      if (in_stream.LastError() != wxSTREAM_NO_ERROR && in_stream.LastError() != wxSTREAM_EOF) {
1038
          return false;
1039
      }
1040
      out_stream.Write(&buffer,in_stream.LastRead());
1041
      if (out_stream.LastError() != wxSTREAM_NO_ERROR) {       
1042
         return false;                                                                   
1043
      }
1044
      int totalKb = out_stream.GetSize() / 1024;
1045
      wxString totalMsg =msg.Format("%i",totalKb);
1046
      showStatusMsg(msg+" "+ totalMsg + " Kb");
1047
      
1048
  }
1049
 
1050
  
1051
  isOk = true;
1052
  /*
1053
  if (isOk) {
1054
    echo("isOk = true");
1055
  } else {
1056
    echo("isOk = false");         
1057
  }
1058
  */
1059
  //delete in_stream;
1060
  //delete out_stream;
1061
  
1062
  //echo("end");
1026

  
1027

  
1028
  //echo(msg.Format("%s --> %s",source.c_str(),finalTarget.c_str()));
1029
  isOk = wxCopyFile(source,finalTarget,false);
1030
	
1031

  
1063 1032
  return isOk;
1064 1033

  
1065 1034
}

Also available in: Unified diff