mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 16:59:33 +01:00 
			
		
		
		
	converter: unicode file names
git-svn-id: trunk@46826 -
This commit is contained in:
		
							parent
							
								
									2fd3d1310c
								
							
						
					
					
						commit
						3ee0203df5
					
				@ -31,6 +31,14 @@ type
 | 
			
		||||
    procedure SaveToFile(const FileName: string); override;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  { TMemoryStreamUTF8 }
 | 
			
		||||
 | 
			
		||||
  TMemoryStreamUTF8 = class(TMemoryStream)
 | 
			
		||||
  public
 | 
			
		||||
    procedure LoadFromFile(const FileName: string);
 | 
			
		||||
    procedure SaveToFile(const FileName: string);
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
procedure LoadStringsFromFileUTF8(List: TStrings; const FileName: string);
 | 
			
		||||
procedure SaveStringsToFileUTF8(List: TStrings; const FileName: string);
 | 
			
		||||
 | 
			
		||||
@ -83,6 +91,32 @@ begin
 | 
			
		||||
  Result:=CompareStr(UTF8LowerCase(List[Index1]),UTF8LowerCase(List[Index2]));
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
{ TMemoryStreamUTF8 }
 | 
			
		||||
 | 
			
		||||
procedure TMemoryStreamUTF8.LoadFromFile(const FileName: string);
 | 
			
		||||
var
 | 
			
		||||
  S: TFileStreamUTF8;
 | 
			
		||||
begin
 | 
			
		||||
  S:=TFileStreamUTF8.Create (FileName,fmOpenRead or fmShareDenyWrite);
 | 
			
		||||
  Try
 | 
			
		||||
    LoadFromStream(S);
 | 
			
		||||
  finally
 | 
			
		||||
    S.free;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMemoryStreamUTF8.SaveToFile(const FileName: string);
 | 
			
		||||
var
 | 
			
		||||
  S: TFileStreamUTF8;
 | 
			
		||||
begin
 | 
			
		||||
  S:=TFileStreamUTF8.Create (FileName,fmCreate);
 | 
			
		||||
  Try
 | 
			
		||||
    SaveToStream(S);
 | 
			
		||||
  finally
 | 
			
		||||
    S.free;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
constructor TFileStreamUTF8.Create(const AFileName: utf8string; Mode: Word);
 | 
			
		||||
begin
 | 
			
		||||
  Create(AFileName,Mode,438);
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,7 @@ interface
 | 
			
		||||
uses
 | 
			
		||||
  // LCL+FCL
 | 
			
		||||
  Classes, SysUtils, LCLProc, Forms, Controls, Dialogs, LConvEncoding,
 | 
			
		||||
  FileUtil, LazFileUtils, contnrs, IniFiles,
 | 
			
		||||
  FileUtil, LazFileUtils, LazUTF8Classes, contnrs, IniFiles,
 | 
			
		||||
  // codetools
 | 
			
		||||
  CodeToolManager, DefineTemplates, CodeCache, LinkScanner, FileProcs, CodeToolsStructs,
 | 
			
		||||
  // IDEIntf
 | 
			
		||||
@ -1234,15 +1234,15 @@ end;
 | 
			
		||||
 | 
			
		||||
function TConvertDelphiProjPack.ExtractOptionsFromCFG(const CFGFilename: string): TModalResult;
 | 
			
		||||
var
 | 
			
		||||
  sl: TStringList;
 | 
			
		||||
  sl: TStringListUTF8;
 | 
			
		||||
  i: Integer;
 | 
			
		||||
  Line, s: string;
 | 
			
		||||
  c: char;
 | 
			
		||||
begin
 | 
			
		||||
  try
 | 
			
		||||
    sl:=TStringList.Create;
 | 
			
		||||
    sl:=TStringListUTF8.Create;
 | 
			
		||||
    try
 | 
			
		||||
      sl.LoadFromFile(UTF8ToSys(CFGFilename));
 | 
			
		||||
      sl.LoadFromFile(CFGFilename);
 | 
			
		||||
      for i:=0 to sl.Count-1 do begin
 | 
			
		||||
        Line:=sl[i];
 | 
			
		||||
        if Line='' then continue;
 | 
			
		||||
 | 
			
		||||
@ -33,8 +33,9 @@ interface
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  // FCL+LCL
 | 
			
		||||
  Classes, SysUtils, Math, LCLProc, Forms, Controls, Grids, LResources, LConvEncoding,
 | 
			
		||||
  Graphics, Dialogs, Buttons, StdCtrls, ExtCtrls, contnrs, FileUtil, LCLType,
 | 
			
		||||
  Classes, SysUtils, Math, LCLProc, Forms, Controls, Grids, LResources,
 | 
			
		||||
  LConvEncoding, Graphics, Dialogs, Buttons, StdCtrls, ExtCtrls, contnrs,
 | 
			
		||||
  FileUtil, LazUTF8Classes, LCLType,
 | 
			
		||||
  // components
 | 
			
		||||
  SynHighlighterLFM, SynEdit, SynEditMiscClasses, LFMTrees,
 | 
			
		||||
  // codetools
 | 
			
		||||
@ -281,16 +282,16 @@ end;
 | 
			
		||||
 | 
			
		||||
function TDFMConverter.ConvertDfmToLfm(const aFilename: string): TModalResult;
 | 
			
		||||
var
 | 
			
		||||
  DFMStream, LFMStream, Utf8LFMStream: TMemoryStream;
 | 
			
		||||
  DFMStream, LFMStream, Utf8LFMStream: TMemoryStreamUTF8;
 | 
			
		||||
begin
 | 
			
		||||
  Result:=mrOk;
 | 
			
		||||
  DFMStream:=TMemoryStream.Create;
 | 
			
		||||
  LFMStream:=TMemoryStream.Create;
 | 
			
		||||
  Utf8LFMStream:=TMemoryStream.Create;
 | 
			
		||||
  DFMStream:=TMemoryStreamUTF8.Create;
 | 
			
		||||
  LFMStream:=TMemoryStreamUTF8.Create;
 | 
			
		||||
  Utf8LFMStream:=TMemoryStreamUTF8.Create;
 | 
			
		||||
  try
 | 
			
		||||
    // Note: The file is copied from DFM file earlier. Load it.
 | 
			
		||||
    try
 | 
			
		||||
      DFMStream.LoadFromFile(UTF8ToSys(aFilename));
 | 
			
		||||
      DFMStream.LoadFromFile(aFilename);
 | 
			
		||||
    except
 | 
			
		||||
      on E: Exception do begin
 | 
			
		||||
        Result:=QuestionDlg(lisCodeToolsDefsReadError, Format(
 | 
			
		||||
@ -319,7 +320,7 @@ begin
 | 
			
		||||
    FixWideString(LFMStream, Utf8LFMStream);
 | 
			
		||||
    // Save the converted file.
 | 
			
		||||
    try
 | 
			
		||||
      Utf8LFMStream.SaveToFile(UTF8ToSys(aFilename));
 | 
			
		||||
      Utf8LFMStream.SaveToFile(aFilename);
 | 
			
		||||
    except
 | 
			
		||||
      on E: Exception do begin
 | 
			
		||||
        Result:=MessageDlg(lisCodeToolsDefsWriteError,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user