ADD: TFileStreamEx class with UTF8 file names support

This commit is contained in:
Alexander Koblov 2008-05-12 06:55:10 +00:00
commit bd962df066
2 changed files with 79 additions and 1 deletions

View file

@ -30,7 +30,7 @@ type
implementation
uses
LCLProc, SysUtils, Classes, uLng, uGlobs, uLog, uShowMsg, uFileProcs, uFindEx, uDCUtils, uOSUtils;
LCLProc, SysUtils, Classes, uLng, uGlobs, uLog, uShowMsg, uFileProcs, uFindEx, uDCUtils, uOSUtils, uFileStreamEx;
procedure TCopyThread.MainExecute;
var

78
ufilestreamex.pas Normal file
View file

@ -0,0 +1,78 @@
{
Double commander
-------------------------------------------------------------------------
TFileStreamEx class with UTF8 file names support.
Copyright (C) 2008 Koblov Alexander (Alexx2000@mail.ru)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit uFileStreamEx;
{$mode objfpc}{$H+}
interface
uses
Classes, RtlConsts, SysUtils, uOSUtils;
type
{ TFileStreamEx class }
TFileStreamEx = class(THandleStream)
private
FHandle: THandle;
FFileName: UTF8String;
public
constructor Create(const AFileName: UTF8String; Mode: Word);
destructor Destroy; override;
property FileName : UTF8String read FFileName;
end;
implementation
{ TFileStreamEx}
constructor TFileStreamEx.Create(const AFileName: UTF8String; Mode: Word);
begin
if Mode = fmCreate then
begin
FHandle:= mbFileCreate(AFileName);
if FHandle < 0 then
raise EFCreateError.CreateFmt(SFCreateError, [AFileName])
else
inherited Create(FHandle);
end
else
begin
FHandle:= mbFileOpen(AFileName, Mode);
if FHandle < 0 then
raise EFOpenError.CreateFmt(SFOpenError, [AFilename])
else
inherited Create(FHandle);
end;
FFileName:= AFileName;
end;
destructor TFileStreamEx.Destroy;
begin
if FHandle >= 0 then FileClose(FHandle);
inherited Destroy;
end;
end.