View Issue Details

IDProjectCategoryView StatusLast Update
0019743LazarusLCLpublic2011-09-07 08:27
ReporterMarkus MüllerAssigned ToFelipe Monteiro de Carvalho 
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionno change required 
PlatformWindowsOSWindowsOS VersionAll
Product Version0.9.31 (SVN)Product Build31683 
Target VersionFixed in Version 
Summary0019743: New CopyFileUTF8()
DescriptionI have add the Procedure CopyFileUTF8.

This feature require the implementation from this bugtracker:
http://bugs.freepascal.org/view.php?id=19742
with the TFileStreamUTF8
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files
  • lcl.diff (1,724 bytes)
    diff -r Lazarus_New\lcl\fileutil.pas Lazarus_Orig\lcl\fileutil.pas
    178,179d177
    < function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
    < function CopyFileUTF8(const SrcFilename, DestFilename: string; PreserveTime: boolean): boolean;
    diff -r Lazarus_New\lcl\include\fileutil.inc Lazarus_Orig\lcl\include\fileutil.inc
    1018,1054d1017
    <   function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
    <  ------------------------------------------------------------------------------}
    < function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
    < begin
    <   Result := CopyFileUTF8(SrcFilename, DestFilename, false);
    < end;
    < 
    < {------------------------------------------------------------------------------
    <   function CopyFileUTF8(const SrcFilename, DestFilename: string PreserveTime:
    <     boolean): boolean;
    <  ------------------------------------------------------------------------------}
    < function CopyFileUTF8(const SrcFilename, DestFilename: String; PreserveTime: Boolean): Boolean;
    < var
    <   SrcFS: TFileStreamUTF8;
    <   DestFS: TFileStreamUTF8;
    < begin
    <   try
    <     SrcFS := TFileStreamUTF8.Create(SrcFilename, fmOpenRead or fmShareDenyWrite);
    <     try
    <       DestFS := TFileStreamUTF8.Create(DestFilename, fmCreate);
    <       try
    <         DestFS.CopyFrom(SrcFS, SrcFS.Size);
    <       finally
    <         DestFS.Free;
    <       end;
    <       if PreserveTime then
    <         FileSetDateUTF8(DestFilename, FileGetDate(SrcFS.Handle));
    <     finally
    <       SrcFS.Free;
    <     end;
    <     Result := True;
    <   except
    <     Result := False;
    <   end;
    < end;
    < 
    < {------------------------------------------------------------------------------
    
    lcl.diff (1,724 bytes)
  • lcl_2.diff (1,716 bytes)
    diff -r Lazarus_New\lcl\fileutil.pas Lazarus_Orig\lcl\fileutil.pas
    178,179d177
    < function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
    < function CopyFileUTF8(const SrcFilename, DestFilename: string; PreserveTime: boolean): boolean;
    diff -r Lazarus_New\lcl\include\fileutil.inc Lazarus_Orig\lcl\include\fileutil.inc
    1018,1054d1017
    <   function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
    <  ------------------------------------------------------------------------------}
    < function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
    < begin
    <   Result := CopyFileUTF8(SrcFilename, DestFilename, false);
    < end;
    < 
    < {------------------------------------------------------------------------------
    <   function CopyFileUTF8(const SrcFilename, DestFilename: string PreserveTime:
    <     boolean): boolean;
    <  ------------------------------------------------------------------------------}
    < function CopyFileUTF8(const SrcFilename, DestFilename: String; PreserveTime: Boolean): Boolean;
    < var
    <   SrcFS: TFileStream;
    <   DestFS: TFileStream;
    < begin
    <   try
    <     SrcFS := TFileStream.CreateUTF8(SrcFilename, fmOpenRead or fmShareDenyWrite);
    <     try
    <       DestFS := TFileStream.CreateUTF8(DestFilename, fmCreate);
    <       try
    <         DestFS.CopyFrom(SrcFS, SrcFS.Size);
    <       finally
    <         DestFS.Free;
    <       end;
    <       if PreserveTime then
    <         FileSetDateUTF8(DestFilename, FileGetDate(SrcFS.Handle));
    <     finally
    <       SrcFS.Free;
    <     end;
    <     Result := True;
    <   except
    <     Result := False;
    <   end;
    < end;
    < 
    < {------------------------------------------------------------------------------
    
    lcl_2.diff (1,716 bytes)

Relationships

related to 0019742 resolvedFelipe Monteiro de Carvalho New TFileStreamUTF8 and TStrings.LoadFromFileUTF8 / SaveToFileUTF8 

Activities

2011-07-14 23:15

 

lcl.diff (1,724 bytes)
diff -r Lazarus_New\lcl\fileutil.pas Lazarus_Orig\lcl\fileutil.pas
178,179d177
< function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
< function CopyFileUTF8(const SrcFilename, DestFilename: string; PreserveTime: boolean): boolean;
diff -r Lazarus_New\lcl\include\fileutil.inc Lazarus_Orig\lcl\include\fileutil.inc
1018,1054d1017
<   function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
<  ------------------------------------------------------------------------------}
< function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
< begin
<   Result := CopyFileUTF8(SrcFilename, DestFilename, false);
< end;
< 
< {------------------------------------------------------------------------------
<   function CopyFileUTF8(const SrcFilename, DestFilename: string PreserveTime:
<     boolean): boolean;
<  ------------------------------------------------------------------------------}
< function CopyFileUTF8(const SrcFilename, DestFilename: String; PreserveTime: Boolean): Boolean;
< var
<   SrcFS: TFileStreamUTF8;
<   DestFS: TFileStreamUTF8;
< begin
<   try
<     SrcFS := TFileStreamUTF8.Create(SrcFilename, fmOpenRead or fmShareDenyWrite);
<     try
<       DestFS := TFileStreamUTF8.Create(DestFilename, fmCreate);
<       try
<         DestFS.CopyFrom(SrcFS, SrcFS.Size);
<       finally
<         DestFS.Free;
<       end;
<       if PreserveTime then
<         FileSetDateUTF8(DestFilename, FileGetDate(SrcFS.Handle));
<     finally
<       SrcFS.Free;
<     end;
<     Result := True;
<   except
<     Result := False;
<   end;
< end;
< 
< {------------------------------------------------------------------------------
lcl.diff (1,724 bytes)

Markus Müller

2011-07-15 07:48

reporter   ~0049999

Last edited: 2011-07-15 08:05

Alternative: You can include in the TFileStream new Procedures "CreateUTF8", then there is no need a new Type TFileStremUTF8. I think this is the better solution.

Sorry, i have post the file "fpc.diff" but this is wrong here, please delete it. (I have not the rights)

I have update the with the lcl_2.diff then I have change some in the issue 0019742

2011-07-15 08:04

 

lcl_2.diff (1,716 bytes)
diff -r Lazarus_New\lcl\fileutil.pas Lazarus_Orig\lcl\fileutil.pas
178,179d177
< function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
< function CopyFileUTF8(const SrcFilename, DestFilename: string; PreserveTime: boolean): boolean;
diff -r Lazarus_New\lcl\include\fileutil.inc Lazarus_Orig\lcl\include\fileutil.inc
1018,1054d1017
<   function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
<  ------------------------------------------------------------------------------}
< function CopyFileUTF8(const SrcFilename, DestFilename: string): boolean;
< begin
<   Result := CopyFileUTF8(SrcFilename, DestFilename, false);
< end;
< 
< {------------------------------------------------------------------------------
<   function CopyFileUTF8(const SrcFilename, DestFilename: string PreserveTime:
<     boolean): boolean;
<  ------------------------------------------------------------------------------}
< function CopyFileUTF8(const SrcFilename, DestFilename: String; PreserveTime: Boolean): Boolean;
< var
<   SrcFS: TFileStream;
<   DestFS: TFileStream;
< begin
<   try
<     SrcFS := TFileStream.CreateUTF8(SrcFilename, fmOpenRead or fmShareDenyWrite);
<     try
<       DestFS := TFileStream.CreateUTF8(DestFilename, fmCreate);
<       try
<         DestFS.CopyFrom(SrcFS, SrcFS.Size);
<       finally
<         DestFS.Free;
<       end;
<       if PreserveTime then
<         FileSetDateUTF8(DestFilename, FileGetDate(SrcFS.Handle));
<     finally
<       SrcFS.Free;
<     end;
<     Result := True;
<   except
<     Result := False;
<   end;
< end;
< 
< {------------------------------------------------------------------------------
lcl_2.diff (1,716 bytes)

Zeljan Rikalo

2011-07-15 17:25

developer   ~0050006

FileUtil.CopyFile() does not work correct for you ?

Markus Müller

2011-07-16 07:06

reporter   ~0050016

Last edited: 2011-07-16 07:16

It work not korrectly.
My PC ist german. When I want use files with polish language like żłąęńćźśó then the routine UTF8ToSys cannot translate this characters into the Ansi Sys Codetable. Result: In CopyFiles, the TFileStream cannot open the File!

See my comments in related 0019742 (link is her in Relationships ^)

In the LCL gives a lot routines xxx and the same xxxUTF8. i think all routines with xxx mut be deleted and all xxxUTF8 renamed into xxx.
(Example: FileExists() delete and Rename FileExistsUTF8() into FileExists() )

Having extra UTF8 routines is bullshit. All normal windows users see the files in explorer, but with Lazarus comes often problems.
In Linux is no problem then Linux uses UTF8 for all file operations.
Using the ansi windows API is the same like DOS from 1990. We have 2011.

I think my solution is only the right way, all other is a compromise solution. I think, make it right, then you have less work.

Vincent Snijders

2011-09-06 00:40

manager   ~0051492

The right solution is a unicode capable RTL.

Felipe Monteiro de Carvalho

2011-09-07 08:27

developer   ~0051543

This patch is wrong, the LCL cannot use features from unstable FPC versions even if that was there.

We can discuss the proper implementation of this in bug 19742

Issue History

Date Modified Username Field Change
2011-07-14 23:15 Markus Müller New Issue
2011-07-14 23:15 Markus Müller File Added: lcl.diff
2011-07-14 23:15 Markus Müller Widgetset => Win32/Win64
2011-07-15 00:59 Maxim Ganetsky Relationship added related to 0019742
2011-07-15 07:48 Markus Müller Note Added: 0049999
2011-07-15 07:55 Markus Müller File Added: fpc.diff
2011-07-15 08:02 Markus Müller Note Edited: 0049999
2011-07-15 08:04 Markus Müller File Added: lcl_2.diff
2011-07-15 08:05 Markus Müller Note Edited: 0049999
2011-07-15 17:25 Zeljan Rikalo LazTarget => -
2011-07-15 17:25 Zeljan Rikalo Note Added: 0050006
2011-07-15 17:25 Zeljan Rikalo Status new => feedback
2011-07-15 21:28 Maxim Ganetsky File Deleted: fpc.diff
2011-07-16 07:06 Markus Müller Note Added: 0050016
2011-07-16 07:10 Markus Müller Note Edited: 0050016
2011-07-16 07:16 Markus Müller Note Edited: 0050016
2011-09-06 00:40 Vincent Snijders Note Added: 0051492
2011-09-07 08:27 Felipe Monteiro de Carvalho Status feedback => resolved
2011-09-07 08:27 Felipe Monteiro de Carvalho Resolution open => no change required
2011-09-07 08:27 Felipe Monteiro de Carvalho Assigned To => Felipe Monteiro de Carvalho
2011-09-07 08:27 Felipe Monteiro de Carvalho Note Added: 0051543