diff --git a/tim2view.lpi b/tim2view.lpi
index f2585a5..1eced2f 100644
--- a/tim2view.lpi
+++ b/tim2view.lpi
@@ -118,20 +118,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tim2view.lps b/tim2view.lps
index 6f8feb1..8a75eb9 100644
--- a/tim2view.lps
+++ b/tim2view.lps
@@ -12,7 +12,7 @@
-
+
@@ -23,9 +23,9 @@
-
-
-
+
+
+
@@ -36,7 +36,7 @@
-
+
@@ -45,37 +45,41 @@
-
+
-
+
-
+
+
-
-
-
+
+
+
+
+
-
-
-
+
+
+
+
@@ -84,7 +88,7 @@
-
+
@@ -93,38 +97,40 @@
-
+
-
+
-
-
-
+
+
+
-
+
-
+
+
-
-
-
+
+
+
+
@@ -133,7 +139,7 @@
-
+
@@ -357,99 +363,127 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ucdimage.pas b/ucdimage.pas
index a4d610f..d3a6890 100644
--- a/ucdimage.pas
+++ b/ucdimage.pas
@@ -40,7 +40,7 @@ procedure ReplaceTimInFileFromMemory(const FileName: string; TIM: PTIM;
implementation
uses
- ucommon, ecc, edc, classes, FileUtil, sysutils;
+ ucommon, ecc, edc, classes, FileUtil, sysutils, lazutf8classes;
function bin2bcd(P: Integer): byte;
begin
@@ -69,7 +69,7 @@ const
var
Sz: cardinal;
pFile: PBytesArray;
- tmp: TFileStream;
+ tmp: TFileStreamUTF8;
begin
Result := False;
Sz := FileSize(FileName);
@@ -80,7 +80,7 @@ begin
pFile := GetMemory(cSectorHeaderSize);
try
- tmp := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
+ tmp := TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyWrite);
tmp.Read(pFile^[0], cSectorHeaderSize);
Result := ((Sz mod cSectorSize) = 0) and (CompareMem(@cSectorHeader, pFile, cSectorHeaderSize));
finally
@@ -94,7 +94,7 @@ procedure ReplaceTimInFileFromMemory(const FileName: string; TIM: PTIM;
type
TSecAddrAndMode = array [0 .. cSectorAddressSize + cSectorModeSize - 1] of byte;
var
- sImageStream: TFileStream;
+ sImageStream: TFileStreamUTF8;
TimOffsetInSector, FirstPartSize, LastPartSize: Integer;
TimSectorNumber, TimStartSectorPos: Integer;
Sector: TCDSector;
@@ -102,8 +102,7 @@ var
P, TIM_FULL_SECTORS: Integer;
SecAddrAndMode: TSecAddrAndMode;
begin
- sImageStream := TFileStream.Create(FileName, fmOpenReadWrite or
- fmShareDenyWrite);
+ sImageStream := TFileStreamUTF8.Create(FileName, fmOpenReadWrite or fmShareDenyWrite);
if not ImageScan then
begin
diff --git a/ucommon.pas b/ucommon.pas
index 44844ef..26f4424 100644
--- a/ucommon.pas
+++ b/ucommon.pas
@@ -3,7 +3,7 @@ unit ucommon;
interface
const
- cProgramName = 'Tim2View SVN.r61 by [Lab 313] (for ' +
+ cProgramName = 'Tim2View SVN.r62 by [Lab 313] (for ' +
{$IFDEF Linux}'Linux' + {$IFEND}
{$IFDEF Darwin}'Mac OS X' + {$IFEND}
{$IFDEF Windows}'Windows' + {$IFEND}
@@ -29,7 +29,6 @@ type
TBytesArray = array [0 .. cMaxFileSize - 1] of byte;
PBytesArray = ^TBytesArray;
-function ExtractJustName(const Path: string): string;
function Min(A, B: Integer): Integer;
function Max(A, B: Integer): Integer;
@@ -53,10 +52,4 @@ begin
Result := B;
end;
-function ExtractJustName(const Path: string): string;
-begin
- Result := ExtractFileName(Path);
- Result := Copy(Result, 1, Length(Result) - Length(ExtractFileExt(Result)));
-end;
-
end.
diff --git a/udrawtim.pas b/udrawtim.pas
index b187e3f..b7da41c 100644
--- a/udrawtim.pas
+++ b/udrawtim.pas
@@ -122,7 +122,7 @@ begin
RW := GetTimRealWidth(TIM);
RH := GetTimHeight(TIM);
- if Surf^ <> nil then Surf^.Free;
+ if (Surf^ <> nil) then Surf^.Free;
Surf^ := TBGRABitmap.Create(RW, RH);
diff --git a/umain.pas b/umain.pas
index 1907d69..6606dde 100644
--- a/umain.pas
+++ b/umain.pas
@@ -204,7 +204,7 @@ begin
if not dlgSavePNG.Execute then Exit;
- Surf^.SaveToFile(dlgSavePNG.FileName);
+ Surf^.SaveToFileUTF8(dlgSavePNG.FileName);
end;
procedure TfrmMain.actTimInfoExecute(Sender: TObject);
@@ -314,10 +314,10 @@ begin
reg.WriteString('', 'Tim File Format');
reg.CloseKey;
reg.OpenKey('Software\Classes\TimFile\DefaultIcon', True);
- reg.WriteString('', '"' + ParamStr(0) +'",0');
+ reg.WriteString('', '"' + ParamStrUTF8(0) +'",0');
reg.CloseKey;
reg.OpenKey('Software\Classes\TimFile\shell\Open\Command', True);
- reg.WriteString('', '"' + ParamStr(0) + '" "%1"');
+ reg.WriteString('', '"' + ParamStrUTF8(0) + '" "%1"');
reg.CloseKey;
finally
reg.Free;
@@ -385,6 +385,7 @@ begin
IsImage := SelectedScanResult.IsImage;
New(Surf_);
+ Surf_^ := nil;
pbProgress.Position := 0;
pbProgress.Max := SelectedScanResult.Count;
@@ -395,16 +396,17 @@ begin
SIZE := ScanTim.Size;
BIT_MODE := ScanTim.BitMode;
- Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)) + cExtractedPngsDir);
- CreateDir(Path);
+ Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStrUTF8(0)) + cExtractedPngsDir);
+ CreateDirUTF8(Path);
Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName));
- CreateDir(Path);
+ CreateDirUTF8(Path);
TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE);
TimToPNG(TIM, cbbCLUT.ItemIndex, Surf_, cbbTranspMode.ItemIndex);
- Surf_^.SaveToFile(Path + FormatPngName(FName, I - 1, BIT_MODE, 0));
+ Surf_^.SaveToFileUTF8(Path + FormatPngName(FName, I - 1, BIT_MODE, 0));
Surf_^.Free;
+ Surf_^ := nil;
FreeTIM(TIM);
@@ -451,10 +453,10 @@ begin
SIZE := ScanTim.Size;
BIT_MODE := ScanTim.BitMode;
- Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)) + cExtractedTimsDir);
- CreateDir(Path);
+ Path := IncludeTrailingPathDelimiter(ExtractFilePath(ParamStrUTF8(0)) + cExtractedTimsDir);
+ CreateDirUTF8(Path);
Path := IncludeTrailingPathDelimiter(Path + ExtractFileName(FName));
- CreateDir(Path);
+ CreateDirUTF8(Path);
TIM := LoadTimFromFile(FName, OFFSET, IsImage, SIZE);
SaveTimToFile(Path + FormatTimName(FName, I - 1, BIT_MODE), TIM);
@@ -528,7 +530,7 @@ var
begin
{$IFnDEF Windows}mnOptions.Enabled := False;{$IFEND}
- Settings := TSettings.Create(ExtractFilePath(ParamStr(0)));
+ Settings := TSettings.Create(ExtractFilePath(ParamStrUTF8(0)));
actStretch.Checked := Settings.StretchMode;
cbbTranspMode.ItemIndex := Settings.TranspMode;
@@ -552,7 +554,7 @@ begin
CheckButtonsAndMainMenu;
- if ParamCount > 0 then ScanPath(ParamStr(1));
+ if ParamCount > 0 then ScanPath(ParamStrUTF8(1));
end;
procedure TfrmMain.FormDropFiles(Sender: TObject;
@@ -722,7 +724,7 @@ begin
btnStopScan.Enabled := True;
btnStopScan.Tag := NativeInt(False);
- if FileExists(Path) then
+ if FileExistsUTF8(Path) then
ScanFile(Path)
else
ScanDirectory(Path);
@@ -762,7 +764,7 @@ var
Dir: string;
begin
Dir := IncludeTrailingPathDelimiter(Directory);
- isFound := FindFirst(Dir + '*', faAnyFile, sRec) = 0;
+ isFound := FindFirstUTF8(Dir + '*', faAnyFile, sRec) = 0;
while isFound do
begin
if (sRec.Name <> '.') and (sRec.Name <> '..') then
@@ -773,9 +775,9 @@ begin
ScanFile(Dir + sRec.Name);
end;
Application.ProcessMessages;
- isFound := FindNext(sRec) = 0;
+ isFound := FindNextUTF8(sRec) = 0;
end;
- FindClose(sRec);
+ FindCloseUTF8(sRec);
end;
procedure TfrmMain.CheckButtonsAndMainMenu;
@@ -949,13 +951,13 @@ end;
function TfrmMain.FormatTimName(const FileName: string; ListIdx_,
BitMode: Integer): string;
begin
- Result := Format(cAutoExtractionTimFormat, [ExtractJustName(FileName), ListIdx_ + 1, BitMode]);
+ Result := Format(cAutoExtractionTimFormat, [ExtractFileNameWithoutExt(FileName), ListIdx_ + 1, BitMode]);
end;
function TfrmMain.FormatPngName(const FileName: string; ListIdx_, BitMode,
Clut: Integer): string;
begin
- Result := Format(cAutoExtractionPngFormat, [ExtractJustName(FileName), ListIdx_ + 1, BitMode, Clut + 1]);
+ Result := Format(cAutoExtractionPngFormat, [ExtractFileNameWithoutExt(FileName), ListIdx_ + 1, BitMode, Clut + 1]);
end;
procedure TfrmMain.ShowTim;
diff --git a/uscanthread.pas b/uscanthread.pas
index 773c6e5..014f06b 100644
--- a/uscanthread.pas
+++ b/uscanthread.pas
@@ -3,7 +3,7 @@ unit uscanthread;
interface
uses
- ucommon, utim, uscanresult, classes, fgl;
+ ucommon, utim, uscanresult, classes, fgl, lazutf8classes;
type
TScanThread = class(TThread)
@@ -16,7 +16,7 @@ type
pClearBufferPosition: Integer;
pClearBufferSize: Integer;
pSectorBufferSize: Integer;
- pSrcFileStream: TFileStream;
+ pSrcFileStream: TFileStreamUTF8;
pStopScan: boolean;
procedure SetStatusText;
procedure StartScan;
@@ -39,8 +39,7 @@ uses
umain, ucdimage, sysutils, FileUtil;
const
- cClearBufferSize = ((cTIMMaxSize div cSectorDataSize) + 1) *
- cSectorDataSize * 2;
+ cClearBufferSize = ((cTIMMaxSize div cSectorDataSize) + 1) * cSectorDataSize * 2;
cSectorBufferSize = (cClearBufferSize div cSectorDataSize) * cSectorSize;
{ TScanThread }
@@ -101,8 +100,7 @@ begin
SectorBuffer := GetMemory(pSectorBufferSize);
ClearBuffer := GetMemory(pClearBufferSize);
- pSrcFileStream := TFileStream.Create(pScanResult.ScanFile, fmOpenRead or
- fmShareDenyWrite);
+ pSrcFileStream := TFileStreamUTF8.Create(pScanResult.ScanFile, fmOpenRead or fmShareDenyWrite);
pSrcFileStream.Position := 0;
diff --git a/utim.pas b/utim.pas
index 1956e5c..01d1c27 100644
--- a/utim.pas
+++ b/utim.pas
@@ -145,7 +145,7 @@ function ConvertCLUTColor(COLOR: TCLUT_COLOR): word;
implementation
uses
- ucdimage, classes, sysutils;
+ ucdimage, classes, sysutils, lazutf8classes;
function ConvertTIMColor(COLOR: word): TCLUT_COLOR;
begin
@@ -366,12 +366,12 @@ var
TimOffsetInSector, FirstPartSize, LastPartSize: Integer;
TimSectorNumber, TimStartSectorPos: Integer;
TIM_BUF: PTIMDataArray;
- sImageStream: TFileStream;
+ sImageStream: TFileStreamUTF8;
Sector: TCDSector;
P, TIM_FULL_SECTORS: Integer;
begin
try
- sImageStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
+ sImageStream := TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyWrite);
TimSectorNumber := Position div cSectorSize + 1;
TimOffsetInSector := Position mod cSectorSize - cSectorInfoSize;
@@ -451,12 +451,12 @@ end;
function LoadTimFromFile(const FileName: string; var Position: Integer;
ImageScan: Boolean; dwSize: Integer): PTIM;
var
- sTIM: TFileStream;
+ sTIM: TFileStreamUTF8;
begin
if not ImageScan then
begin
try
- sTIM := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
+ sTIM := TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyWrite);
Result := LoadTimFromStream(sTIM, Position, dwSize);
finally
sTIM.Free;
@@ -469,13 +469,12 @@ end;
procedure SaveTimToFile(const FileName: string; TIM: PTIM);
var
- tmp: TMemoryStream;
+ tmp: TFileStreamUTF8;
begin
if TIM = nil then Exit;
- tmp := TMemoryStream.Create;
+ tmp := TFileStreamUTF8.Create(FileName, fmOpenWrite or fmCreate, fmShareDenyRead);
tmp.Write(TIM^.DATA^[0], TIM^.dwSize);
- tmp.SaveToFile(FileName);
tmp.Free;
end;